Code Monkey home page Code Monkey logo

Comments (2)

glime-ai avatar glime-ai commented on September 27, 2024
  1. The behavior you're observing is consistent with the purpose of the CreateBookmark() method. When you call context.CreateBookmark(), it indicates a point where the workflow should pause and wait for an external event to resume. If you place a Console.WriteLine after CreateBookmark(), it will execute immediately because the workflow has not yet been suspended. To suspend the workflow in the middle of an activity, you should ensure that CreateBookmark() is the last call in the activity's execution path that should run before pausing.

  2. Regarding the RunAsync() method, it seems there might be a discrepancy between the documentation and the actual API. The documentation you're referring to might be outdated or incorrect. To resume a workflow, you typically need to provide a bookmark ID to the RunAsync() method. If the overload you're looking for doesn't exist, you may need to use a different method or a different overload of RunAsync() that is available in the version of Elsa you are using.

For the most accurate and up-to-date information on how to suspend and resume workflows, I recommend checking the latest official Elsa documentation or the source code directly. If the documentation is indeed outdated, you can open an issue on the Elsa GitHub repository or contact the maintainers to request an update.

For now, you can try using the WorkflowInstanceFilter to find the workflow instance and then use the RunWorkflowOptions to specify the bookmark ID when calling RunAsync(). Here's an example based on the information from the GitHub issues:

var options = new WorkflowInstanceFilter
{
    Id = InstanceId,
};
var workflowInstance = await _workflowInstanceStore.FindAsync(options);
var workflowState = workflowInstance.WorkflowState;
var bookmark = workflowState.Bookmarks.FirstOrDefault(b => /* your condition here */);
var runOptions = new RunWorkflowOptions { BookmarkId = bookmark?.Id };

var result = await _workflowRunner.RunAsync(workflow, runOptions);

Please note that the above code is just an example and may need to be adjusted based on the actual API and your specific use case.

This comment was generated by Glime.

from elsa-core.

VijoPlays avatar VijoPlays commented on September 27, 2024

Right, in that case the first point can be ignored (since it was mostly a question anyway).

The second point still stands and using the RunAsync method like in the example will run the entire workflow, not just resume it.

from elsa-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.