f# - How do I create a job queue using a MailboxProcessor? -


I am trying to model an asynchronous work processing structure using the mailbox processor. Start, stop, stop, and resume my job processor to my needs. Can I create a break / restart functionality with the mailbox processor? Also should I be able to stop and start? I am trying to model after the Windows service

I have a system in C #, which has been implemented using Row / Threads. I was looking for design options, when I saw a mailbox processor I believe I can use it but it can not figure out how to handle the above scenarios, is it possible to achieve this functionality?

Sure :) Just keep jobs in an internal queue and calculate through the queue when the job processor In any other mode, the processor is in start mode, just enter new jobs until the processor goes into start mode.

  Type 'a msg = //' | Get started | Stop it. Stop (Unit -> unit) type of efficiency () = UB = mailbox processor. Start (Funniest Inbox -> REC Loop Position (Jobs: System.clubs.jenorick.que & lt; _ & gt;) = async {if position = Jobs while initializing.Account & gt; 0f = Jobs Msg (start) Stop! - Stop -> Stop the loop jobs | Jobs (f) - Duplicate () F.) Come on !sg = Inbox. Jobs> .NQ (F); Return! Loop State Job | Stop -> Return ()} Loop Start (New Istmkcollekshn. Jenrikkkyuyuand & lt; _ & gt; ())) member. This.Resume () = mb.Post (start) member this.Stop () = MB. Post (wait) member this.page () = MB Post (Pause) Members This Question: When (f) = MB.Post (job f)  

This class behaves as expected: You can add jobs to Paus St., but they only start in the starting position. Once the Qi of the process closes, it can not be restarted, and no drowning job will be done (This behavior is easy enough to change so that instead of killing the queue, it will only stop. Job does not enqueue) Tate.

If you need two-way communication between the mailbox processor and your code, use it.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -