Hello,
I'm using several wclOPPClient objects to send files to the phone. The whole procedure is asynchronous. At one place I BeginInvoke() some starting method, in this method I create an object that encapsulate an array of wclOPPClient (say, WCLSender) and call WCLSender .SendFiles():
sender = new WCLSender(arrBtAddr, arrFiles, senderWaitTime);
eventFileSending = new EventFileSending(sender.SendFiles);
eventFileSending.BeginInvoke(new AsyncCallback(OnFileSendingFinish), eventFileSending);
In completion method I do some post-processing of the files sent (or rejected, or timed out).
That's where I have a question. I've defined an array of ManualResetEvent in my WCLSender class, so they may be Set() at various stages. In sender.SendFiles(), I call Connect() on all wclOPPClient objects. Then I want to just wait in SendFiles() until all handlers signal either error or completion (by setting manual event). If I wait for events to be signalled on the same thread where I call Connect(), my OnConnect callbacks are never called. If I call wclOPPClient.Connect() on the different thread and wait for the same events in SendFiles() - I do hit the callbacks. Threads must continue looping, otherwise callbacks are not called.
Am I completely wrong here with such design or missing something obvious?