/// <summary> /// 同步创建连接 /// </summary> /// <param name="timeout"></param> public void Connect(int timeout) { var a = new SyncInvoker <Exception>(); BeginConnect(a.Callback); if (!a.Wait(timeout)) { throw new RpcException(RpcErrorCode.ConnectionTimeout, RemoteUri.ToString(), "Connection timeout", null); } }
public override void ExecuteAsync() { SetStatus(TaskStatus.Running); TorrentService s = Banshee.ServiceStack.ServiceManager.Get <TorrentService> (); downloader = s.Download(RemoteUri.ToString(), Path.GetDirectoryName(LocalPath)); torrent = TorrentService.Bus.GetObject <ITorrent> (TorrentService.BusName, downloader.GetTorrent()); downloader.StateChanged += OnDownloaderStateChanged; // There are no events on the torrent IDownloader to indicate when the stats have updated // Manually ping the SetProgress event, otherwise migo never notices progress changing System.Threading.ThreadPool.QueueUserWorkItem(UpdateProgress); }