|
-
October 1st, 2011, 09:00 PM
#12
Re: Sharing objects between application instances using WCF
 Originally Posted by Eri523
While the log in the sample WcfShareTest.log was generated by manually starting the server and then two clients, SimulStart.log was created by quasi-simultaneously starting two client instances from a trivial batch file, without the server already running at that time. This was intended to stress-test the server start-up scenario. The test exposed exactly the desired behaviour: Eventually there was one server instance running with two clients attached. What pretty much puzzles me, though, is how that happened.  According to the log both clients enter the "Starting server app..." part of the code within a time span of 17 ms from each other, start to wait for server start-up with a distance of 15 ms and eventually report a successful server start within 4 ms. Yet there's just one server instance running. I don't think there was a second server instance for a short time that then died silently.
I think you have some issues with regard to the use of the manualset event.
I see it's a manual reset named event, but I don't see where you set it or reset it. If you don't ever set it, then won't WaitOne(0) always false?
At any rate, you might consider using a named mutex to protect the server initialization code.
Code:
bool mutexWasCreated;
Mutex^ m = gcnew Mutex( false, "WcfShareTestServerLaunchedEvent", mutexWasCreated );
// Block other processes
m->WaitOne( );
// Start up the server
if( mutexWasCreated )
{
// Startup up WCF server
}
// Allow access to other processes
m->ReleaseMutex( );
The code above should block additional processes from attempting to access the server while its initializing.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|