public IAsyncResult BeginWaitForRequest(TimeSpan timeout, AsyncCallback callback, object state)
 {
     ThrowIfDisposedOrNotOpen();
     try
     {
         File.Delete(PathToFile(LocalAddress.Uri, "request"));
         FileSystemWatcher watcher = new FileSystemWatcher(LocalAddress.Uri.AbsolutePath, "request");
         watcher.EnableRaisingEvents = true;
         WaitForRequestAsyncResult asyncResult = new WaitForRequestAsyncResult(watcher, state, timeout);
         watcher.Changed += new FileSystemEventHandler((obj, ea) =>
         {
             if (ea.ChangeType == WatcherChangeTypes.Changed)
             {
                 asyncResult.Complete(false);
                 if (callback != null)
                     callback(asyncResult);
             }
         });
         return asyncResult;
     }
     catch (IOException exception)
     {
         throw ConvertException(exception);
     }
 }
示例#2
0
        public bool EndWaitForRequest(IAsyncResult result)
        {
            WaitForRequestAsyncResult <TChannel> result2 = result as WaitForRequestAsyncResult <TChannel>;

            if (result2 != null)
            {
                return(result2.End());
            }
            CompletedAsyncResult.End(result);
            return(true);
        }
        public bool EndWaitForRequest(IAsyncResult result)
        {
            WaitForRequestAsyncResult waitForRequestResult = result as WaitForRequestAsyncResult;

            if (waitForRequestResult != null)
            {
                return(waitForRequestResult.End());
            }
            else
            {
                CompletedAsyncResult.End(result);
                return(true);
            }
        }