I'm currently using BeginInvoke(with ASyncCallback) to handle my Client\Server communications with remoting. Here is my current setup:
...
//Main
Remoter.StationDelegate svd = new Remoter.StationDelegate(IPCObjectInstance, &Remoter.GetStationInformation);
AsyncCallback callback = new AsyncCallback(this, &CentralControlClient.StationInformation_Recieved);
IAsyncResult arValSet = svd->BeginInvoke(WaitForNewFile, callback, true);
...
void StationInformation_Recieved(IAsyncResult theResult)
{
AsyncResult theAsyncResult= (AsyncResult)theResult;;
Remoter.StationDelegate theDelegate = (BaseRemotingObject.StationDelegate)
theAsyncResult->AsyncDelegate;;
Station result = theDelegate->EndInvoke(theResult);
...
}
I'm running into the following issue: When I start my client from VisualStudio->Start Debugging, the Received event fires 4+ times. It will throw an exception stating "you cannot have multiple EndInvokes, yatta yatta.
I set breakpoints and verified, I am only hitting BeginInvoke once, but the EndInvoke is attempting to get called multiple times.
If I hit VS->Start without debugging, or run from explorer, or even run from explorer and than attach to the process, the finished evnet only gets hit once (using Console.Writeline to verify).
I cannot figure out what debugging could have that would affect the event getting fire 4 times.
Thanks in advance for the help