0

I have a web service (WS) and a console application (CA).

The WS accepts data and inserts into database. The CA reads this data and performs operations. The synchronization works as follows. The WS has the code:

MyProject.Web.MvcApplication.newDataServiceMessageSignal.Set()

where newDataServiceMessageSignal is declared in the global.asax file

public static EventWaitHandle newDataServiceMessageSignal;

and on application_start, is given the following value:

protected void Application_Start()
{
..
    newDataServiceMessageSignal = new EventWaitHandle(false, EventResetMode.AutoReset, "MySignalName");
..
}

In the CA, there is a while loop which is always true and a WaitOne on the EventWaitHandle

var newMessageSignal = new EventWaitHandle(false, EventResetMode.AutoReset, "MySignalName");
while(true)
{
    newMessageSignal.WaitOne();
    //Do Something Useful
}

My problem is, this code works fine while running on IIS Express (debugging in Visual Studio) but fails while I publish and deploy the application and then run it. The CA waits continuously even if WS sets the signal (I'm assuming WS sets the signal as the statement before that is a database commit and its successful). I'm not able to figure out, why it is behaving this way.

Any help appreciated, Thank you.

Pazza22
  • 554
  • 3
  • 18
  • 1
    I think WS and CA is not running with the same user. Try to use the same user for debugging purpose and look at this : http://stackoverflow.com/questions/2590334/creating-a-cross-process-eventwaithandle. It may helps. – Cyril Durand Apr 29 '15 at 07:47
  • @CyrilDurand Thank You. That was precisely what was happening. Turns out that I have to use the other constuctor `EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew, EventWaitHandleSecurity eventSecurity)` Looks like I have to read up a bit more. – Pazza22 May 05 '15 at 09:53
  • Could you elaborate on this @Pazza22? – cjones26 Oct 08 '15 at 12:31

0 Answers0