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


C# BackgroundWorker.RunWorkerAsync方法代码示例

本文整理汇总了C#中System.ComponentModel.BackgroundWorker.RunWorkerAsync方法的典型用法代码示例。如果您正苦于以下问题:C# BackgroundWorker.RunWorkerAsync方法的具体用法?C# BackgroundWorker.RunWorkerAsync怎么用?C# BackgroundWorker.RunWorkerAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.BackgroundWorker的用法示例。


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

示例1: ParseTopPerson

 public static void ParseTopPerson(string html, Action<List<Person>> finished)
 {
     BackgroundWorker bw = new BackgroundWorker();
     bw.DoWork += new DoWorkEventHandler((sender, e) =>
     {
         List<Person> TopPerson = new List<Person>();
         HtmlDocument hDoc = new HtmlDocument();
         hDoc.LoadHtml(html);
         var tableRows = hDoc.DocumentNode.SelectNodes(Constants.Instance.XPATH_GAME_TOP_RESULT);
         foreach (var node in tableRows)
         {
             var results = ChildElementsInTableRow(node);
             if (results.Count == Constants.Instance.COUNT_GAME_TOP_RESULT_COLUMNS)
             {
                 var person = TopPersonFromStrings(results);
                 if (person.Total != 0)
                 {
                     TopPerson.Add(person);
                 }
             }
         }
         finished(TopPerson);
     });
     bw.RunWorkerAsync();
 }
开发者ID:nkwsqyyzx,项目名称:BetStrategy,代码行数:25,代码来源:HtmlParser.cs

示例2: ParseRecommends

 public static void ParseRecommends(string html, Action<List<Recommend>> finished)
 {
     BackgroundWorker bw = new BackgroundWorker();
     bw.DoWork += new DoWorkEventHandler((sender, e) =>
     {
         List<Recommend> allRecommends = new List<Recommend>();
         HtmlDocument hDoc = new HtmlDocument();
         hDoc.LoadHtml(html);
         var tableRows = hDoc.DocumentNode.SelectNodes(Constants.Instance.XPATH_GAME_SHOW_RESULT);
         foreach (var node in tableRows)
         {
             var results = ChildElementsInTableRow(node);
             if (results.Count == Constants.Instance.COUNT_GAME_SHOW_RESULT_COLUMNS)
             {
                 var rec = RecommendFromStrings(results);
                 if (IsValidRecommend(rec))
                 {
                     allRecommends.Add(rec);
                 }
             }
         }
         finished(allRecommends);
     });
     bw.RunWorkerAsync();
 }
开发者ID:nkwsqyyzx,项目名称:BetStrategy,代码行数:25,代码来源:HtmlParser.cs

示例3: btVolDoc_Click

        private void btVolDoc_Click(object sender, EventArgs e)
        {
            worker = new BackgroundWorker();
            worker.DoWork += new DoWorkEventHandler(VolDocAsync);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(VolDocAsyncCompleta);

            btVolDoc.Text = "Pesquisando";
            btVolDoc.Enabled = false;

            if (radioMatriz.Checked) // Matriz
            {
                query = "SELECT  trim(trf_ref) || trf_ser as serie from transferido where trf_vol  = '"+ numericDoc.Value+ "'  and trf_dtc is null and ROWNUM <= 500 order by trf_ser";
                //Console.WriteLine(query);
                worker.RunWorkerAsync();
            }
            else // Filial
            {
                if(intFilial.Value != 0) // Não é filial 0
                {
                   // query = "SELECT mov_ser as serie from movimento where mov_doc = '" + numericDoc.Value + "' and mov_sed ='" +intFilial.Value + "' and ROWNUM <= 500";
                    query = "SELECT  trim(mov_ref) || mov_ser as mercadoria from movimento where mov_doc = '" + numericDoc.Value + "' and mov_sed ='" + intFilial.Value + "'";
                    worker.RunWorkerAsync();
                }
                else
                {
                    MessageBox.Show("Precisa selecionar uma filial");
                    btVolDoc.Text = "Pesquisar";
                    btVolDoc.Enabled = true;
                }
            }
        }
开发者ID:EduardoRenz,项目名称:Acerto,代码行数:31,代码来源:Principal.VolDoc.cs

示例4: NetworkClient

 public NetworkClient(System.Net.IPAddress serverAddress, int port)
 {
     TcpClient client = new TcpClient();
     client.Connect(serverAddress, port);
     _stream = client.GetStream();
     _connected = true;
     BackgroundWorker streamWorker = new BackgroundWorker();
     streamWorker.WorkerSupportsCancellation = true;
     streamWorker.DoWork += ReadFromStream;
     streamWorker.RunWorkerCompleted += (s, a) =>
                                     {
                                         if (_connected)
                                         {
                                             streamWorker.RunWorkerAsync(_stream);
                                         }
                                     };
     streamWorker.RunWorkerAsync(_stream);
     StreamError += (ex, stream) =>
                     {
                         if (ex is IOException || ex is InvalidOperationException || ex is ObjectDisposedException)
                         {
                             _connected = false;
                             Console.WriteLine("Lost connection: {0}", ex.Message);
                             Console.Write("> ");
                         }
                         else
                         {
                             throw ex;
                         }
                     };
 }
开发者ID:Mellen,项目名称:Networking-Samples,代码行数:31,代码来源:NetworkClient.cs

示例5: MainWindow

        public MainWindow()
        {
            string[] args = Environment.GetCommandLineArgs();
              InitializeComponent();
              string[] validUsers = { "usernames" };//update to run
              string strUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
              int indDomain = strUserName.LastIndexOf("\\")+1;
              string user = strUserName.Substring(indDomain, strUserName.Length - indDomain);
              int i = args.Count();
              if (true) { //update for validuser check
            BackgroundWorker bw1 = new BackgroundWorker();
            if (args.Count() > 1) {
              string fileName = args[1];
              bw1.DoWork += new DoWorkEventHandler(updateFromFile);
              bw1.RunWorkerAsync(fileName);
              initBtn.IsEnabled = false;
              updateBtn.IsEnabled = false;
              pBar.Visibility = Visibility.Hidden;
            } else {
            bw1.DoWork += new DoWorkEventHandler(getPList);
            bw1.RunWorkerAsync();
            initBtn.IsEnabled = false;
            updateBtn.IsEnabled = false;
            pBar.Visibility = Visibility.Hidden;
            }
              } else {
            initBtn.IsEnabled = false;
            updateBtn.IsEnabled = false;
            status.Content = "Not an allowed user, contact SCT.";
            pBar.Visibility = Visibility.Hidden;
              }

              //status.Content = strUserName;
        }
开发者ID:plausiblecontrol,项目名称:DevTrackJiraQuery,代码行数:34,代码来源:MainWindow.xaml.cs

示例6: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            _serverProcessor = new ServerProcessor();
            _serverProcessor.MessageReceived += _serverProcessor_MessageReceived;

            BackgroundWorker bg = new BackgroundWorker();

            bg.DoWork += delegate { _serverProcessor.RunServer(); };
            bg.RunWorkerCompleted += delegate { bg.RunWorkerAsync(); };
            bg.RunWorkerAsync();
        }
开发者ID:bedashii,项目名称:ReturnMedz,代码行数:11,代码来源:Form1.cs

示例7: ServerForm_Load

        private void ServerForm_Load(object sender, EventArgs e)
        {
            _bg = new BackgroundWorker();
            _bg.DoWork += delegate { _processor.Initialize(); };
            _bg.RunWorkerCompleted += delegate { _bg.RunWorkerAsync(); };
            _bg.RunWorkerAsync();

            this.Text += " " + _processor.ServerDetails;
            NotifyIconServer.Text = _processor.ServerDetails;
            WindowState = FormWindowState.Minimized;
        }
开发者ID:bedashii,项目名称:ReturnMedz,代码行数:11,代码来源:ServerForm.cs

示例8: CreateDictionaryHash

 public void CreateDictionaryHash()
 {
     var prefixTreeThread = new BackgroundWorker();
     prefixTreeThread.DoWork += ReadPrefixTree;
     prefixTreeThread.RunWorkerCompleted += ReadPrefixTreeComplete;
     prefixTreeThread.RunWorkerAsync();
 }
开发者ID:huynguyen1412,项目名称:Phone,代码行数:7,代码来源:PrefixTree.cs

示例9: UpdateCheck

 private static void UpdateCheck()
 {
     Game.PrintChat("<font color='#33FFFF'>>>LeagueSharp.Common loaded <<");
     var bgw = new BackgroundWorker();
     bgw.DoWork += bgw_DoWork;
     bgw.RunWorkerAsync();
 }
开发者ID:ramboozer,项目名称:LeagueSharpCommon,代码行数:7,代码来源:Common.cs

示例10: UpdateCheck

 private static void UpdateCheck()
 {
     Game.PrintChat("<font color='#33FFFF'> .: Orianna by trelli loaded :.");
     var bgw = new BackgroundWorker();
     bgw.DoWork += bgw_DoWork;
     bgw.RunWorkerAsync();
 }
开发者ID:AwkwardDev,项目名称:LeagueSharp2,代码行数:7,代码来源:OriannaUpdater.cs

示例11: btnLoadData_Click

        private void btnLoadData_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog dlgFolder = new FolderBrowserDialog())
            {
                if (dlgFolder.ShowDialog() == DialogResult.OK)
                {

                    for (int i = 0; i < this.feretDataSet.faces.Rows.Count; i++)
                    {
                        this.feretDataSet.faces.Rows[i].Delete();

                    }

                    updateDatabase();

                    BackgroundWorker worker = new BackgroundWorker();
                    worker.WorkerReportsProgress = true;
                    worker.DoWork += new DoWorkEventHandler(worker_DoWork);
                    worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
                    worker.RunWorkerAsync(dlgFolder.SelectedPath);

                    lstInfo.Enabled = false;
                    //lstSelect.Enabled = false;
                    btnLoadData.Enabled = false;
                    btnSaveSetList.Enabled = false;
                    dataGridView1.Enabled = false;
                }

            }
        }
开发者ID:NoxHarmonium,项目名称:enform,代码行数:30,代码来源:frmFeretExplorer.cs

示例12: Start

        /// <summary>
        /// Lance une tache dans un background worker.
        /// </summary>
        /// <param name="taskFunc">Tache à exécuter.</param>
        /// <param name="completionAction">Action à réaliser après l'exécution. Recoit l'exception si une exception a eu lieu.</param>
        public static void Start(Action taskFunc, Action<Exception> completionAction)
        {
            if (taskFunc == null)
            {
                throw new ArgumentNullException("taskFunc");
            }

            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += new DoWorkEventHandler(
                delegate
                {
                    taskFunc();
                });

            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    if (completionAction != null)
                    {
                        completionAction(e.Error);
                    }
                });

            backgroundWorker.RunWorkerAsync();
        }
开发者ID:csongfr,项目名称:OGP,代码行数:31,代码来源:BackgroundTask.cs

示例13: Twitch

 public Twitch(string channel, string ircAdress, int port) {
     smiles = new Dictionary<string, TwitchSmile>();
     channelName = channel.Trim().ToLower();
     ircUrl = ircAdress;
     this.port = port;
     BackgroundWorker bg = new BackgroundWorker();
     bg.DoWork += bg_DoWork;
     bg.RunWorkerAsync();
     regexSignsEmotions = new string[]{"B-?\\)",
                                     "\\:-?[z|Z|\\|]",
                                     "\\:-?\\)",
                                     "\\:-?\\(",
                                     "\\:-?(p|P)",
                                     "\\;-?(p|P)",
                                     "\\&lt\\;3",
                                     "\\:-?(?:\\/|\\\\)(?!\\/)",
                                     "\\;-?\\)",
                                     "R-?\\)",
                                     "[o|O](_|\\.)[o|O]",
                                     "\\:-?D",
                                     "\\:-?(o|O)",
                                     "\\&gt\\;\\(",
                                     "\\:\\&gt\\;",
                                     "\\:-?(S|s)",
                                     "#-?[\\\\/]",
                                     "\\&lt\\;\\]",
                                     ":-?(?:7|L)"};
 }
开发者ID:Slashka-DK,项目名称:BlitzChat,代码行数:28,代码来源:Twitch.cs

示例14: RefreshAllAsync

 public override void RefreshAllAsync()
 {
     BackgroundWorker refreshAllWorker = new BackgroundWorker();
     refreshAllWorker.DoWork += new DoWorkEventHandler(RefreshWorker_DoWork);
     refreshAllWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RefreshWorker_RunWorkerCompleted);
     refreshAllWorker.RunWorkerAsync();
 }
开发者ID:TlhanGhun,项目名称:digiTweetSnarlEdition,代码行数:7,代码来源:RepliesManager.cs

示例15: RunAsync

 public void RunAsync()
 {
     worker = new BackgroundWorker();
     worker.DoWork += OnMethodStarted;
     worker.RunWorkerCompleted += OnMethodFinished;
     worker.RunWorkerAsync();
 }
开发者ID:genesissupsup,项目名称:TomatoTimer,代码行数:7,代码来源:BackgroundWorkerAsyncMethod.cs


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