当前位置: 首页>>代码示例>>C#>>正文


C# DoWorkEventHandler类代码示例

本文整理汇总了C#中DoWorkEventHandler的典型用法代码示例。如果您正苦于以下问题:C# DoWorkEventHandler类的具体用法?C# DoWorkEventHandler怎么用?C# DoWorkEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DoWorkEventHandler类属于命名空间,在下文中一共展示了DoWorkEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadMediaInfoWorker

        internal UploadMediaInfoWorker(FileInfo inputFile)
        {
            Logger.Info("Starting new UploadMediaInfoWorker on " + inputFile.FullName);
            this.inputFile = inputFile;

            DoWork += new DoWorkEventHandler(UploadMediaInfoWorker_DoWork);
        }
开发者ID:noahsw,项目名称:highlight-hunter,代码行数:7,代码来源:UploadMediaInfoWorker.cs

示例2: ProcessBackground

 public ProcessBackground(int Max, DoWorkEventHandler DoWork, ProgressChangedEventHandler worker_ProgressChanged)//最大值和标题
 {
     progressForm = new FrmAutoUpdate();
     progressForm.progressBarDownload.Value = 0;
     progressForm.Show();
     SetbackgroundWorker(DoWork, worker_ProgressChanged);
 }
开发者ID:jojozhuang,项目名称:Projects,代码行数:7,代码来源:ProcessBackground.cs

示例3: BackgroundConnectionHelper

 public BackgroundConnectionHelper(DoWorkEventHandler AsyncDelegate, RunWorkerCompletedEventHandler GUIDelegate)
 {
     backgroundWorker = new BackgroundWorker();
     backgroundWorker.DoWork += AsyncDelegate;
     backgroundWorker.RunWorkerCompleted += GUIDelegate;
     backgroundWorker.WorkerSupportsCancellation = true;
 }
开发者ID:pixellos,项目名称:TCPConnector,代码行数:7,代码来源:BackgroundConnectionHelper.cs

示例4: runAsyncLoadingAction

        /// <summary>
        /// Shows loading form and executes given action as async background worker.
        /// </summary>
        /// <param name="action">Async action to execute</param>
        /// <param name="Text">Text to display on loading form</param>
        /// <param name="invertOrder">true - action will be runned first, loading form will be showed as second action | false - first will be showed loading form, second will be executed given action</param>
        /// <param name="sleep">delay in ms to wait between given action and loading form showing</param>
        public void runAsyncLoadingAction(DoWorkEventHandler action, String Text, bool invertOrder = false, int sleep=0)
        {
            this.Enabled = false;
            loadingText = Text;
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += new DoWorkEventHandler(handleLoading);

            BackgroundWorker bw2 = new BackgroundWorker();
            if (action != null)
            {
                bw2.DoWork += new DoWorkEventHandler(action);
                bw2.RunWorkerCompleted += handleLoadingEnd;
            }
            if (!invertOrder)
            {
                if (action != null)
                {
                    bw2.RunWorkerAsync();
                    if (sleep>0)
                        System.Threading.Thread.Sleep(sleep);
                }
                bw.RunWorkerAsync();
            }
            else {
                bw.RunWorkerAsync();
                if (action != null)
                {
                    if (sleep>0)
                        System.Threading.Thread.Sleep(sleep);
                    bw2.RunWorkerAsync();
                }
            }
        }
开发者ID:tousekdominik,项目名称:SkSys,代码行数:40,代码来源:TemplateForm.cs

示例5: ProgressDialog

        /// <summary>
        /// ProgressDialogクラスのコンストラクタ
        /// </summary>
        /// <param name="caption">タイトルバーに表示するテキスト</param>
        /// <param name="doWorkHandler">バックグラウンドで実行するメソッド</param>
        /// <param name="argument">doWorkで取得できるパラメータ</param>
        public ProgressDialog(string caption,
            DoWorkEventHandler doWork,
            object argument)
        {
            InitializeComponent();

            //初期設定
            this.workerArgument = argument;
            this.Text = caption;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterParent;
            this.ControlBox = false;
            this.CancelButton = this.cancelAsyncButton;
            this.messageLabel.Text = "";
            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = 100;
            this.progressBar1.Value = 0;
            this.cancelAsyncButton.Text = "キャンセル";
            this.cancelAsyncButton.Enabled = true;
            this.backgroundWorker1.WorkerReportsProgress = true;
            this.backgroundWorker1.WorkerSupportsCancellation = true;

            //イベント
            this.Shown += new EventHandler(ProgressDialog_Shown);
            this.cancelAsyncButton.Click += new EventHandler(cancelAsyncButton_Click);
            this.backgroundWorker1.DoWork += doWork;
            this.backgroundWorker1.ProgressChanged +=
                new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
            this.backgroundWorker1.RunWorkerCompleted +=
                new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
        }
开发者ID:jkamiya5,项目名称:WordConv,代码行数:38,代码来源:ProgressDialog.cs

示例6: AsyncWorker

 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncWorker"/> class.
 /// </summary>
 /// <param name="name">The name used in log messages.</param>
 /// <param name="worker">The worker delegate.</param>
 /// <param name="completed">The completed delegate.</param>
 public AsyncWorker(
     string name,
     DoWorkEventHandler worker,
     RunWorkerCompletedEventHandler completed)
     : this(name, worker, null, completed)
 {
 }
开发者ID:hmuralt,项目名称:appccelerate,代码行数:13,代码来源:AsyncWorker.cs

示例7: FormInfo

 public FormInfo(Form owner,
                 string Message,
                 DoWorkEventHandler DoWork,
                 RunWorkerCompletedEventHandler RunWorkerCompleted)
 {
     doInitialize(owner, Message, DoWork, RunWorkerCompleted, null);
 }
开发者ID:rhenium,项目名称:OpenTween,代码行数:7,代码来源:FormInfo.cs

示例8: RegisterDoWork

        private static void RegisterDoWork(this BackgroundWorker bw, DoWorkEventHandler doWorkEvent = null)
        {
            bw.WorkerSupportsCancellation = true;

            //默认实现
            if (doWorkEvent == null)
            {
                doWorkEvent = (sender, e) =>
                {
                    var ce = e.Argument as CustomerDoWorkEventArgs;//获取传递参数
                    BackgroundWorker cBw = ce.ExecBackgroundWorker;
                    int count = Convert.ToInt32(ce.ExecParameter.ToString(), 10);
                    for (int i = 0; i < count; i++)
                    {
                        if (!cBw.CancellationPending)//永远可以取消
                        {
                            //汇报当前处理进度
                            cBw.ReportProgress(i, "正在处理第" + i + "条数据");
                            Thread.Sleep(500);
                        }
                        else
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                    e.Result = "执行操作完成的结果:1";
                };

            }

            bw.DoWork += doWorkEvent;
        }
开发者ID:ZhouLinWorkGroup20140106,项目名称:BackgroundWorkerTest,代码行数:33,代码来源:BackgroundWorkerExtension.cs

示例9: QBDepositWorker

 public QBDepositWorker(DailyDeposit dailyDeposit)
 {
     _dailyDeposit = dailyDeposit;
     DoWork += new DoWorkEventHandler(QBDepositWorker_DoWork);
     WorkerReportsProgress = true;
     WorkerSupportsCancellation = true;
 }
开发者ID:jshafer817,项目名称:EaglesoftQuickbooks,代码行数:7,代码来源:QBDepositWorker.cs

示例10: WorkerHelper

 /// <summary>
 /// Constructor that accepts Event handlers for executing async thread
 /// </summary>
 /// <param name="WorkerProcess">Worker Process Handler</param>
 /// <param name="WorkProgressHandler">Progress Changed Event Handler</param>
 /// <param name="WorkCompletedHandler">Call back method handler which is invoked once the Worker Process is completed</param>
 public WorkerHelper(DoWorkEventHandler WorkerProcess, ProgressChangedEventHandler WorkProgressHandler, RunWorkerCompletedEventHandler WorkCompletedHandler)
 {
     this.DoWork += WorkerProcess;
     this.ProgressChanged += WorkProgressHandler;
     this.RunWorkerCompleted += WorkCompletedHandler;
     this.WorkerReportsProgress = true;
 }
开发者ID:itisashokkumar,项目名称:3M,代码行数:13,代码来源:WorkerHelper.cs

示例11: ConsoleWorker

        public ConsoleWorker(int maximumCount)
        {
            _countProtector = new Object();

            _maxCount       = maximumCount;
            _workerCallback = new AsyncCallback(this.OnRunWorkerCompleted);
            _eventHandler   = new DoWorkEventHandler(this.OnDoWork);
        }
开发者ID:jogibear9988,项目名称:SharpVectors,代码行数:8,代码来源:ConsoleWorker.cs

示例12: InitNewBackgroundWorker

 public static BackgroundWorker InitNewBackgroundWorker(DoWorkEventHandler doWorkEvent, ProgressChangedEventHandler progressChangedEvent, RunWorkerCompletedEventHandler runWorkerCompletedEvent)
 {
     var bw = new BackgroundWorker();
     bw.RegisterDoWork(doWorkEvent);
     bw.RegisterProgressChanged(progressChangedEvent);
     bw.RegisterRunWorkerCompleted(runWorkerCompletedEvent);
     return bw;
 }
开发者ID:ZhouLinWorkGroup20140106,项目名称:BackgroundWorkerTest,代码行数:8,代码来源:BackgroundWorkerExtension.cs

示例13: PublishWorkerHost

        internal PublishWorkerHost(string outputDirectoryPath)
        {
            DoWork += new DoWorkEventHandler(SaveWorkerHost_DoWork);
            WorkerReportsProgress = true;
            WorkerSupportsCancellation = true;

            this.outputDirectoryPath = outputDirectoryPath;
        }
开发者ID:noahsw,项目名称:highlight-hunter,代码行数:8,代码来源:PublishWorkerHost.cs

示例14: RunBackground

 private void RunBackground(DoWorkEventHandler doWork, object argument, RunWorkerCompletedEventHandler runWorkerCompleted)
 {
     using (BackgroundWorker backgroundWorker = new BackgroundWorker())
     {
         backgroundWorker.DoWork += doWork;
         backgroundWorker.RunWorkerCompleted += runWorkerCompleted;
         backgroundWorker.RunWorkerAsync(argument);
     }
 }
开发者ID:kevins1022,项目名称:Altman,代码行数:9,代码来源:FileManager.cs

示例15: startWork

 public void startWork(DoWorkEventHandler work, String description)
 {
     if (bg_worker.IsBusy) return;
     isProgressBarActive = true;
     StatusText = description;
     bg_worker.DoWork += work;
     bg_worker.RunWorkerAsync();
     bg_worker.DoWork -= work;
 }
开发者ID:GrayJumba,项目名称:Onion,代码行数:9,代码来源:SDStatusBar.xaml.cs


注:本文中的DoWorkEventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。