locked
When is it necessary to block in the Event Handlers for Job Events RRS feed

  • Question

  • Hello All,

    I've recently started working with the .NET MS Job Scheduler API and I've found the examples at http://msdn.microsoft.com/en-us/library/cc907080(VS.85).aspx very useful, however I have a couple of questions.

    The example given for Creating and Submitting a job at http://msdn.microsoft.com/en-us/library/cc853426(VS.85).aspx uses the ManualResetEvent which causes the example given to block until the JobState is Canceled, Failed, or Finished, because the JobStateEvnetHandler only calls ManualResetEvent.Set() on these conditions.

    The application that I am working on sets a Property in my class, that the EventHandler updates when the state changes.  My question is this:

    Are there any reasons why I should block in my EventHandlers if I do not need to wait for the entire job to complete before continuting in my application?

    Aquil
    Thursday, January 28, 2010 2:44 AM

Answers

  • Thank you for your reply Patrick.  I was confused about the ManualResetEvent.Set() method.

    Sunday, January 31, 2010 8:51 PM

All replies

  • Hi Aquil,

    The example you referenced does not block inside the event handler. It blocks at the manualEvent.WaitOne() line in Main(). If your application does not need to wait for the job to change state, then you do not need to block or wait for events as in the example.

    Does that answer your question?

    Regards,

    Patrick
    Friday, January 29, 2010 5:32 PM
  • Thank you for your reply Patrick.  I was confused about the ManualResetEvent.Set() method.

    Sunday, January 31, 2010 8:51 PM