I'm building a simple task manager that will at this moment execute tasks in a serial manner. I have been reading about threads in flex and it seems it is not quite clear/prepared for real threads.
What I'm looking at this moment is a way to execute a method at the beginning or end of a flash builder update. This method will be the one that will take the responsibility to start tasks added in the previous update. The removing of finished tasks will be done through event notification (the task will notify it finished) then the scheduler will remove it and dispatch the message again to let the outside world know the task was over.
A rough workflow of the system woudl be:
1) Add Tasks to the scheduler. And listen to events of the task (finished, etc...)
2) At the beginning/ End of a flex update (don't know if this really happen) Start tasks waiting. And run tasks that have a runnable method per update.
3) When a task finishes it notifies the scheduler and it is removed from the scheduler queue and redispatches the event to let the outside world the task finsihed.
Could anybody suggest the correct place to have a method like this? Any suggestion to the scheduler?.
Thanks in advance,
Aaron.
Based on your description you don't seem to be doing anything new and that unique. I'd start first with researching existing task and concurrency solutions. If they won't do what you want, extending the code will probably still be easier than starting from scratch.
Get familiar first with Cairngorm 3 Tasks and/or Parsley Tasks.
Also take a look at the callLater() method.
Finally there is the GreenThreads project.
Related
We need to trigger an another event when two independent async events are completed. We are publishing individual rabbitmq messages on the completion of each async event. I went through RabbitMQ documentation but did not find a way to handle this elegantly.
Scenario:
- Task A completed
- Task B completed
Start task C only if A & B are completed.
Is there any design pattern that can help me here ? Anything outside RabbitMQ is also fine. We would like to achieve this without polling. Tasks are totally independent happening in 3 different systems.
Can celery help in this?
We implemented this using Aggregator pattern in RabbitMQ itself.
http://www.enterpriseintegrationpatterns.com/patterns/messaging/Aggregator.html
We created a topic (aggregator). Task A and Task B are subscribed to it. Whenever any of the task gets completed, message is being pushed to the topic. Topic is maintaining the state of taskA and taskB and publishes another message once both tasks are completed.
i'm new to web development, so bear with. I just came across Celery, an asynchronous task queue. After reading the documentation, what i get that celery is adding a delay to a code and then run its process in background. I don't really get it, i thought it's just like a normal AJAX, if yes, what's the advantage using this so-called asynchronous task queue, if not, what's the difference between a normal ajax call and async task queue. Would be good if you guys give me some real world example. Thanks.
I have a vb.net 4.0 UI that basically allows users to search for data on a SQL Server 2008 database and update/manipulate it. All of the communication with the database is done through stored procs. One of the update procs may take up to 6 minutes to process - currently the users just see the "processing..." message until the update has completed, and then they are shown the results.
I think this is a good candidate for a background task. I would like the users to be able to invoke the request, and then continue to do other work in the UI. When the task finishes it would notify them of the results. Can I accomplish this with threading? I'm new to threading but given some literature and an example or 2 I could be on my way. I've done some Googling but it's not apparent in the examples whether the user can continue working in the UI while the task executes. Are there other options to accomplish what I have described?
thanks.
There a number of options for running a background task, but in .net 4.0, the neatest is probably to make use of the TPL (Task Parallel Library). You can execute a background task as follows:
Task.Factory.StartNew(()=>SomeMethod());
Detail info can be found here.
http://msdn.microsoft.com/en-us/library/dd460717.aspx
Remember though, that if you need to perform any UI updates when returning from this call, you will need to dispatch that back on to the UI thread.
The TPL also has mechanism for running a continuation on the Dispatcher thread.
Whilst the background task is running, the UI thread will not be blocked.
Team:
I need to invoke a WF activity (XAML) from a WF service (XAMLX) asynchronously. I am already referencing the Microsoft.Activities.Extensions framework and I'm running on the Platform Update 1 for the state machine -- so if the solution is already in one of those libraries I'm ready!
Now, I need to invoke that activity (XAML) asynchronously -- but it has an output parameter that needs to set a variable in the service (XAMLX). Can somebody please provide me a solution to this?
Thanks!
* UPDATE *
Now I can post pictures, * I think *, because I have enough reputation! Let me put a couple out here and try to better explain my problem. The first picture is the WF Service that has the two entry points for the workflow -- the second is the workflow itself.
This workflow is an orchestration mechanism that constantly restarts itself, and has some failover mechanisms (e.g. exit on error threshold and soft exit) so that we can manage our queue of durable transactions using WF!
Now, we had this workflow working great when it was all one WF Service because we could call the service, get a response back and send the value of that response back into another entry point in a trigger to issue a soft exit. However, a new requirement has arrisen asking us to make the workflow itself a WF activity in another project and have the Receive/Send-Reply sequences in the WF Service Application project.
However, we need to be able to startup this workflow and forget about it -- then let it know somehow that a soft exit is necessary later on down the road -- but since WF executes on a single thread this has become a bit challenging at best.
Strictly speaking in XAML activities Parallel and ParallelForEach are how you perform asynchrony.
The workflow scheduler only uses a single thread (much like UI) so any activity that is running will typically be running on the same thread, unless it implements AsyncCodeActivity, in which case you are simply handing back the scheduler thread to the runtime while waiting for a callback from whichever async code your AsyncCodeActivity implementation is calling.
Therefore are you sure this is what you want to achieve? Do you mean you want to run it after you have sent your initial response? In this case place your activity after the Send Reply.
Please provide more info if these suggestions don't answer your question./
Update:
The original requirement posed (separating implementation from the service Receive/Send activities) may actually be solved by hosting the target activity as a service. See the following link
http://blog.petegoo.com/index.php/2011/09/02/building-an-enterprise-workflow-system-with-wf4/
I want each sequence inside a foreach<T> activity running in a different thread. Is this possible by using WWF 4.0? If not, how can I achieve multithreading in WWF 4.0?
It depends on the kind of work you are doing. By default the workflow scheduler will only execute a single activity in a workflow at the time, no way around that. The parallel activities schedule multiple child activities at the same time but they don't execute in parallel.
The big exception to the rule is AsyncCodeActivity type activities. The scheduler will execute another activity as soon as they are doing some asynchronous stuff. Now this works best with IO bound work like database access or network IO but that is not a requirement.
So to achieve true parallelism in your workflows you need to be use a combination of one of the parallel activities with activities deriving from AsyncCodeActivity.
To achieve parallel execution of a foreach, use ParallelForEach.