///////////////////////////////////////////////////////////// /// #region 实现 // 这个方法开始一个异步的计算 // 首先,它检查提供的taskId是否为unique的,如果是,就创建一个新的 WorkerEventHandler,并调用BeginInvoke方法开始计算 public virtual void ValidateAsync( ref List <ProxyInfo> proxyList, object taskId) { // 为taskId创建一个AsyncOperation对象 AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // 开始异步操作 WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke( ref proxyList, asyncOp, null, null); }
public virtual void LoadAsync(Stream stream, object taskId) { AsyncOperation asyncOp = CreateOperation(taskId); m_workerDelegate = new WorkerEventHandler(LoadWorker); m_workerDelegate.BeginInvoke(stream, asyncOp, m_completionMethodDelegate, null, null); }
public virtual void MatMulAsync(double[,] mat1, double[,] mat2, int size, object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke( mat1, mat2, size, asyncOp, null, null); }
///////////////////////////////////////////////////////////// /// #region Implementation // <snippet3> // This method starts an asynchronous calculation. // First, it checks the supplied task ID for uniqueness. // If taskId is unique, it creates a new WorkerEventHandler // and calls its BeginInvoke method to start the calculation. public virtual void CalculatePrimeAsync( int numberToTest, object taskId) { // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke( numberToTest, asyncOp, null, null); }
public void Run() { WorkerEventHandler workerDelegate = new WorkerEventHandler(TranslateManager.TranslateWorker); int cnt = 0; foreach (ServiceItemSetting ts in translatorsSettings) { cnt++; int delay = GetDelayBeforeRun(ts); if (delay == 0) { workerDelegate.BeginInvoke( ts, this, null, null); } else { string timerName = ts.ServiceItem.FullName + "_" + Environment.TickCount.ToString() + "_" + cnt.ToString(); TaskConveyer.QueueTimer(timerName, DelayedProcess, ts, delay, Timeout.Infinite); timers.Add(timerName); } } }
public void EasyEventAsync(string requester, object userState) { AsyncOperation asynchronousOps = AsyncOperationManager.CreateOperation(userState); WorkerEventHandler worker = new WorkerEventHandler(EasyEventExecutor); //Asynchronous Execution worker.BeginInvoke(requester, asynchronousOps, null, null); }
/// <summary> /// Starts specified user operation asynchronously. /// </summary> /// <param name="userState">User state.</param> /// <param name="userOperation">User operation.</param> public void Start(object userState, Func <TResult> userOperation) { AsyncOperation asyncOperation = AsyncOperationManager.CreateOperation(userState); WorkerEventHandler workerDelegate = this.OperationWorker; workerDelegate.BeginInvoke(asyncOperation, userOperation, null, null); }
public virtual void SaveAsync(Dump dump, DumpFormat format, Stream stream, object taskId) { SaveInfo info = new SaveInfo(dump, format, stream); AsyncOperation asyncOp = CreateOperation(taskId); m_workerDelegate = new WorkerEventHandler(SaveWorker); m_workerDelegate.BeginInvoke(info, asyncOp, m_completionMethodDelegate, null, null); }
/// <summary> /// 异步操作行为 /// </summary> /// <param name="taskId"></param> public void Async(object taskId) { //验证构造函数 ValidateCompletedEventArgs(CreateConstructedFunctionSignature(typeof(Exception), typeof(Boolean), typeof(Object), typeof(TResult)), new Exception(), false, new Object(), default(TResult)); AsyncOperation asyncOp = base.BeginAsync(taskId); // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(Worker); workerDelegate.BeginInvoke(asyncOp, null, null); }
/// <summary> /// 异步操作行为 /// </summary> /// <param name="taskId"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> /// <param name="arg3"></param> /// <param name="arg4"></param> public void Async(object taskId, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { //验证构造函数 ValidateCompletedEventArgs(CreateConstructedFunctionSignature(typeof(Exception), typeof(Boolean), typeof(Object), typeof(T1), typeof(T2), typeof(T3), typeof(T4)), new Exception(), false, new Object(), arg1, arg2, arg3, arg4); ValidateProgressChangedEventArgs(CreateConstructedFunctionSignature(typeof(Int32), typeof(Object), typeof(TRef)), 0, new Object(), new TRef()); AsyncOperation asyncOp = base.BeginAsync(taskId); // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(Worker); workerDelegate.BeginInvoke(asyncOp, arg1, arg2, arg3, arg4, null, null); }
public virtual void IsPrimeAsync(decimal number, object userSuppliedState) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userSuppliedState); if (!_userStateToLifetime.TryAdd(userSuppliedState, asyncOp)) { throw new ArgumentException("Task ID parameter must be unique", "taskId"); } WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke(number, asyncOp, null, null); }
public void CrawlAsync(ICrawlDaddy crawl) { // Create an AsyncOperation for taskId. _asyncOp = AsyncOperationManager.CreateOperation(crawl.CrawlerId); crawl.DomainCrawlStarted += crawl_DomainCrawlStarted; crawl.DomainCrawlEnded += crawl_DomainCrawlEnded; crawl.LinkCrawlCompleted += crawl_LinkCrawlCompleted; crawl.ExternalLinksFound += crawl_ExternalLinksFound; // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(CrawlWorker); workerDelegate.BeginInvoke(crawl, _asyncOp, null, null); }
public virtual void GenerateAsync(GenerationParameter parameter, object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) throw new ArgumentException("Task ID parameter must be unique", "taskId"); userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(GenerateWorker); workerDelegate.BeginInvoke(parameter, asyncOp, null, null); }
public static AsyncGuessState GuessAsync(string phrase, NetworkSetting networkSetting, EventHandler <GuessCompletedEventArgs> guessCompletedHandler) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(DateTime.Now.Ticks); AsyncGuessState state = new AsyncGuessState(phrase, networkSetting, asyncOp, guessCompletedHandler); WorkerEventHandler workerDelegate = new WorkerEventHandler(GuessWorker); workerDelegate.BeginInvoke( state, null, null); return(state); }
public virtual void MatMulAsync(double[][] mat1, double[][] mat2, object TaskID) { AsyncOperation ao = AsyncOperationManager.CreateOperation(TaskID); lock (userState.SyncRoot) { if (userState.Contains(TaskID)) { throw new ArgumentException("ArgumentError", "TaskID"); } userState[TaskID] = ao; } WorkerEventHandler worker = new WorkerEventHandler(CalculateWorker); worker.BeginInvoke(mat1, mat2, ao, null, null); }
/// <summary> /// 异步下载并指定任务Id /// </summary> /// <param name="manifest"></param> /// <param name="taskId"></param> public void DownloadAsync(Manifest manifest, object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException("参数taskId必须是唯一的", "taskId"); } userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(DownloadWorker); workerDelegate.BeginInvoke(asyncOp, null, null); }
public virtual void CalculatePrimeAsync(int numberToTest, object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException("Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke(numberToTest, asyncOp, null, null); }
public void FibonacciAsync(int k, object userState) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState); lock (tasks.SyncRoot) { if (tasks.Contains(userState)) { throw new ArgumentException("User state parameters must be unique", "userState"); } tasks[userState] = asyncOp; } WorkerEventHandler worker = new WorkerEventHandler(FibonacciWorker); worker.BeginInvoke(k, asyncOp, null, null); }
private void EventStatusGetAsync(TimeSpan span, object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (tasks.SyncRoot) { if (tasks.Contains(taskId)) { throw new ArgumentException("Task identifier must be unique.", nameof(taskId)); } tasks[taskId] = asyncOp; } WorkerEventHandler worker = EventStatusDoWork; worker.BeginInvoke(span, asyncOp, null, null); }
public virtual void GenerateAsync(GenerationParameter parameter, object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException(Resources.TaskId, "taskId"); } userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(GenerateWorker); workerDelegate.BeginInvoke(parameter, asyncOp, null, null); }
// This method starts an asynchronous calculation. // First, it checks the supplied task ID for uniqueness. // If taskId is unique, it creates a new WorkerEventHandler // and calls its BeginInvoke method to start the calculation. public virtual void RequestDataAsync( EnumRequestMethod requestMethod, object taskId) { //HttpWebRequest requestObj = GetRequestObj(requestMethod); //RequestState requestState = new RequestState(); //requestState.request = requestObj; //requestState.RequestId = taskId; //requestState.IsRequestString = false; //requestState.Context = SynchronizationContext.Current; //if (requestMethod == EnumRequestMethod.POST) //{ // requestState.PostData = this.PostData; //} //requestState.RequestMethod = requestMethod; //this.BeginHttpReqeust(requestState); // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(RequestDataWorker); workerDelegate.BeginInvoke( requestMethod, asyncOp, null, null); }
/// <summary> /// Sends the service request async. /// </summary> /// <param name="context">The context.</param> /// <param name="state">The state.</param> public void SendServiceRequestAsync(IHttpCommand context, object state) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(state); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(state)) { throw new ArgumentException("state must be unique for async operation", "state"); } userStateToLifetime[state] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(SendServiceRequestAsyncWrapper); workerDelegate.BeginInvoke(context, asyncOp, null, null); }
/// <summary> /// Asynchoronous version of the method /// </summary> /// <param name="message">just simple message to display</param> /// <param name="userState">Unique value to maintain the task</param> /// public void MathMulAsync(double[][] mat1, double[][] mat2, object userState) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState); //Multiple threads will access the task dictionary, so it must be locked to serialze access lock (tasks.SyncRoot) { if (tasks.Contains(userState)) { throw new ArgumentException("User state parameter must be unique", "userState"); } tasks[userState] = asyncOp; } WorkerEventHandler worker = new WorkerEventHandler(MathMulWorker); //Execute process Asynchronously worker.BeginInvoke(mat1, mat2, asyncOp, null, null); }
/// <summary> /// Method to udpate Writeback status for a given WR. This method will be called by client asyncronously. Client needs to register the event WriteBackProcessCompleted to get the notification of method completion /// </summary> /// <param name="p_wrNumber">WR number</param> /// <param name="taskId"></param> public void UpdateWriteBack(string p_wrNumber, object taskId) { string sJobIdentifier = string.Empty; this.cc = new ConfirmComplete(); this.WriteBackProcessCompleted += WritebackClass_WriteBackProcessCompleted; this.cc.enableOK = false; this.cc.statusText = "Writing data to WMIS..."; this.cc.SetDesktopLocation(0, 0); this.cc.Show(m_oApp.ApplicationWindow); this.cc.TopMost = true; this.cc.Text = "WR# " + p_wrNumber; // When the cc form closes, dispose of it properly. this.cc.FormClosed += Cc_FormClosed; InitializeWriteBackDelegates(); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); string sUserName = m_oApp.DataContext.DatabaseUserName; string sPasswordString = m_oApp.DataContext.ViewerConnectionString.Substring(m_oApp.DataContext.ViewerConnectionString.IndexOf("Password="******"Password="******"Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(UpdateWritebackStatusWorker); workerDelegate.BeginInvoke( p_wrNumber, asyncOp, sUserName, sPasswordString, null, null ); }
/// <summary> /// Begins listening for data packets. /// </summary> public override void BeginListen() { if (_isListening) { throw new InvalidOperationException("Already listening."); } this.EndPoint = new IPEndPoint(IPAddress.Any, _port); _socket = new UdpClient(this.EndPoint) { EnableBroadcast = true }; AsyncOperation asyncOperation = AsyncOperationManager.CreateOperation(this); WorkerEventHandler worker = new WorkerEventHandler(Listen); _isListening = true; worker.BeginInvoke(asyncOperation, null, null); }
public virtual void MatMulAsync(double[,] mat1, double[,] mat2, object taskId) { AsyncOperation asyncOperation = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOperation; } WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke(mat1, mat2, asyncOperation, new AsyncCallback(CalculateCompleted), null); }
private void deviceSearcher_DeviceSearchCompleted(object sender, DeviceSearchCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { this.RaiseUploadingCompletedEvent(new AsyncCompletedEventArgs(e.Error, e.Cancelled, null)); } else { if (Encoding.ASCII.GetString(e.DeviceResponse).ToLower().Contains(this.deviceSearcher.Pattern.ToLower())) { bootLoaderMode = false; } AbstractChannel port = new SerialportChannel(e.Port); port.ControllerAddress = e.DeviceResponse[0]; this.devicePort = this.solution.LastWorkedPort = port; AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(Guid.NewGuid()); this.userStateToLifeTime.Add(asyncOp); WorkerEventHandler workerDelegate = new WorkerEventHandler(this.Upload); workerDelegate.BeginInvoke(port, null, null); } }
public void RunAsync(params object[] arguments) { // Create an AsyncOperation for taskId. this.taskId = Guid.NewGuid(); this.asyncOperation = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (this.userStateToLifetime.SyncRoot) { if (this.userStateToLifetime.Contains(taskId)) { throw new ArgumentException("Task ID parameter must be unique", "taskId"); } this.userStateToLifetime[taskId] = this.asyncOperation; } // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(this.DoWork); workerDelegate.BeginInvoke(asyncOperation, arguments, null, null); }
public void waitForPD() { Canceled = false; AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(new Guid()); WorkerEventHandler workerDelegate = new WorkerEventHandler(doWaitForPD); workerDelegate.BeginInvoke(asyncOp, null, null); }
public void Run() { WorkerEventHandler workerDelegate = new WorkerEventHandler(TranslateManager.TranslateWorker); int cnt = 0; foreach(ServiceItemSetting ts in translatorsSettings) { cnt++; int delay = GetDelayBeforeRun(ts); if(delay == 0) { workerDelegate.BeginInvoke( ts, this, null, null); } else { string timerName = ts.ServiceItem.FullName + "_" + Environment.TickCount.ToString() + "_" + cnt.ToString(); TaskConveyer.QueueTimer(timerName, DelayedProcess, ts, delay, Timeout.Infinite); timers.Add(timerName); } } }
/// <summary> /// Запускает поиск устройства /// </summary> public void StartSearch() { lock (this.requestingPorts) { if (this.requestingPorts.Count != 0) { throw new Exception("Поиск устройства уже запущен, необходимо дождаться завершения"); } } this.deviceResponse = null; this.canceled = false; if (devicePort != null) { byte[] res = { }; try { devicePort.Open(); res = devicePort.SendRequest(this.Request, this.Pattern.Length); if (res != null && (Encoding.ASCII.GetString(res).ToLower().Contains(this.Pattern.ToLower()) || Encoding.ASCII.GetString(res).ToLower().Contains(this.BootPattern.ToLower()))) { this.deviceResponse = res; } } catch { } finally { devicePort.Close(); } } if (deviceResponse != null) { DeviceSearchCompletedEventArgs e = new DeviceSearchCompletedEventArgs(this.devicePort, this.deviceResponse, null, canceled); if (this.DeviceSearchCompleted != null) { this.DeviceSearchCompleted(this, e); } } else { this.devicePort = null; this.progress = 0; this.portsCount = 0; string[] portNames = SerialPort.GetPortNames(); this.portsCount = portNames.Length; foreach (string portName in portNames) { if (!this.requestingPorts.Keys.Contains(portName)) { WorkerEventHandler workerDelegate = new WorkerEventHandler(this.SearchDevice); AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(portName); this.requestingPorts.Add(portName, asyncOp); workerDelegate.BeginInvoke(portName, asyncOp, null, null); } } } }
public static AsyncGuessState GuessAsync(string phrase, NetworkSetting networkSetting, EventHandler<GuessCompletedEventArgs> guessCompletedHandler) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(DateTime.Now.Ticks); AsyncGuessState state = new AsyncGuessState(phrase, networkSetting, asyncOp, guessCompletedHandler); WorkerEventHandler workerDelegate = new WorkerEventHandler(GuessWorker); workerDelegate.BeginInvoke( state, null, null); return state; }
///////////////////////////////////////////////////////////// /// #region 实现 // 这个方法开始一个异步的计算 // 首先,它检查提供的taskId是否为unique的,如果是,就创建一个新的 WorkerEventHandler,并调用BeginInvoke方法开始计算 public virtual void ValidateAsync( ref List<ProxyInfo> proxyList, object taskId) { // 为taskId创建一个AsyncOperation对象 AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // 开始异步操作 WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke( ref proxyList, asyncOp, null, null); }
public void start(int port) { Canceled = false; m_port = port; if (m_server!= null) { stop(); } AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(this); // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(doWork); workerDelegate.BeginInvoke( asyncOp, null, null); }
// This method starts an asynchronous calculation. // First, it checks the supplied task ID for uniqueness. // If taskId is unique, it creates a new WorkerEventHandler // and calls its BeginInvoke method to start the calculation. public virtual void CalculatePrimeAsync( int numberToTest, object taskId) { // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(CalculateWorker); workerDelegate.BeginInvoke( numberToTest, asyncOp, null, null); }
/// <summary> /// 异步下载并指定任务Id /// </summary> /// <param name="manifest"></param> /// <param name="taskId"></param> public void DownloadAsync(Manifest manifest,object taskId) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException("参数taskId必须是唯一的", "taskId"); } userStateToLifetime[taskId] = asyncOp; } WorkerEventHandler workerDelegate = new WorkerEventHandler(DownloadWorker); workerDelegate.BeginInvoke(asyncOp, null, null); }
// This method starts an asynchronous calculation. // First, it checks the supplied task ID for uniqueness. // If taskId is unique, it creates a new WorkerEventHandler // and calls its BeginInvoke method to start the calculation. public void SearchAsync( FlightSearchParams flightSearchParams, ISupplier supplier, object taskId) { // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (_userStateToLifetime.SyncRoot) { if (_userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } _userStateToLifetime[taskId] = asyncOp; } // Start the asynchronous operation. var workerDelegate = new WorkerEventHandler(SearchWorker); workerDelegate.BeginInvoke( flightSearchParams, supplier, asyncOp, null, null); IsBusy = true; }
public virtual void RequestStringAsync( EnumRequestMethod requestMethod, object taskId) { //HttpWebRequest requestObj = GetRequestObj(requestMethod); //RequestState requestState = new RequestState(); //requestState.request = requestObj; //requestState.RequestId = taskId; //requestState.IsRequestString = true; //requestState.Context = SynchronizationContext.Current; //if (requestMethod == EnumRequestMethod.POST) //{ // requestState.PostData = this.PostData; //} //requestState.RequestMethod = requestMethod; //this.BeginHttpReqeust(requestState); // Create an AsyncOperation for taskId. AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(taskId); // Multiple threads will access the task dictionary, // so it must be locked to serialize access. lock (userStateToLifetime.SyncRoot) { if (userStateToLifetime.Contains(taskId)) { throw new ArgumentException( "Task ID parameter must be unique", "taskId"); } userStateToLifetime[taskId] = asyncOp; } // Start the asynchronous operation. WorkerEventHandler workerDelegate = new WorkerEventHandler(RequestStringWorker); workerDelegate.BeginInvoke( requestMethod, asyncOp, null, null); }