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.