/// <summary>Completes the specified asynchronous receive operation.</summary> /// <param name="asyncResult"></param> /// <returns></returns> public string EndLog(IAsyncResult asyncResult) { // Retrieve the delegate. LogItemCallback caller = (LogItemCallback)asyncResult.AsyncState; // Call EndInvoke to retrieve the results. string msg = (string)caller.EndInvoke(asyncResult); return(msg); }
/// <summary> /// AsyncLog /// </summary> /// <returns></returns> internal void LogAsync(LoggerLevel level, string text) { LogItemCallback caller = new LogItemCallback(LogItemWorker); // Initiate the asychronous call. IAsyncResult result = caller.BeginInvoke(level, text, CreateCallBack(), caller); result.AsyncWaitHandle.WaitOne(); //while (!result.IsCompleted) //{ // Thread.Sleep(10); //} // Call EndInvoke to wait for the asynchronous call to complete, // and to retrieve the results. caller.EndInvoke(result); }