/// <summary>
 /// 异步工作器回调事件通知
 /// </summary>
 /// <param name="handle">异步工作器句柄</param>
 /// <param name="data">工作器获取的数据,例如异步获取到的数据集合。</param>
 /// <param name="exception">工作器内引发的异常</param>
 public AsyncWorkerCallbackEventArgs(AsyncWorkerHandle <T> handle, T data, Exception exception)
     : base()
 {
     this.handle    = handle;
     this.data      = data;
     this.exception = exception;
 }
示例#2
0
        /// <summary>
        /// 异步工作器开始工作
        /// </summary>
        /// <param name="timeoutSeconds">设置工作器超时时长,单位为秒,默认为10秒。工作器超时之后工作将被取消。</param>
        /// <returns>异步工作器句柄</returns>
        public AsyncWorkerHandle <T> StartWork(int timeoutSeconds)
        {
            if (timeoutSeconds < 0)
            {
                throw new ArgumentException("Invalid timeout seconds.", "timeoutSeconds");
            }

            this.worker.RunWorkerAsync();
            SetTimeoutTimer(timeoutSeconds);
            handle = new AsyncWorkerHandle <T>(this);

            return(handle);
        }