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


C# ComponentModel.BackgroundWorker类代码示例

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


BackgroundWorker类属于System.ComponentModel命名空间,在下文中一共展示了BackgroundWorker类的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: AddDirectoryAsync

        private IEnumerable<XElement> AddDirectoryAsync(DirectoryInfo dir, string collectionId, ref int count, int fnumber,
            BackgroundWorker worker)
        {
            List<XElement> addedElements = new List<XElement>();
            // добавление коллекции
            string subCollectionId;
            List<XElement> ae = this.cass.AddCollection(dir.Name, collectionId, out subCollectionId).ToList();
            if (ae.Count > 0) addedElements.AddRange(ae);

            count++;
            foreach (FileInfo f in dir.GetFiles())
            {
                if (worker.CancellationPending) break;
                if (f.Name != "Thumbs.db")
                    addedElements.AddRange(this.cass.AddFile(f, subCollectionId));
                count++;
                worker.ReportProgress(100 * count / fnumber);
            }
            foreach (DirectoryInfo d in dir.GetDirectories())
            {
                if (worker.CancellationPending) break;
                addedElements.AddRange(AddDirectoryAsync(d, subCollectionId, ref count, fnumber, worker));
            }
            return addedElements;
        }
开发者ID:agmarchuk,项目名称:CManager,代码行数:25,代码来源:CM_WindowDND.cs

示例3: 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

示例4: ScannerProgress

 public ScannerProgress(string folder, BackgroundWorker worker)
 {
     this.worker = worker;
     InitializeComponent();
     UpdateFolder(folder);
     UpdateAction("");
 }
开发者ID:binaryage,项目名称:xrefresh,代码行数:7,代码来源:ScannerProgress.cs

示例5: CPromoCashableDetails

        public CPromoCashableDetails(string RouteNumber, DateTime StartDate, DateTime EndDate,int UserNo)
        {
            InitializeComponent();
            _worker = new BackgroundWorker();
            _worker.WorkerReportsProgress = true;
            _worker.WorkerSupportsCancellation = true;

            CurrencySymbol = CurrencySymbol.GetCurrencySymbol();
            this.RouteNumber = RouteNumber;
            this.StartDate = StartDate;
            this.EndDate = EndDate;
            this.UserNo = UserNo;

            // For resizing columns automatically.
            GridView gv = lvPromoCashable.View as GridView;
            if (gv != null)
            {
                foreach (GridViewColumn gvc in gv.Columns)
                {
                    gvc.Width = gvc.ActualWidth;
                    if (gvc.Width == 0.0 || gvc.Width == 0)
                        gvc.Width = 0;
                    else
                        gvc.Width = Double.NaN;
                }
            }        
        }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:27,代码来源:CPromoCashableDetails.xaml.cs

示例6: 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

示例7: 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

示例8: Form1

        public Form1()
        {
            InitializeComponent();
            util = new Utility();
            mainJobList = new BindingList<IndeedDetails>();
            filtered = new List<IndeedDetails>();
            sortKeeper = new GridSortBy();
            //worker stuff
            worker = new BackgroundWorker();

            worker.DoWork += BackgroundWorkerDoWork;
            worker.RunWorkerCompleted +=
               BackgroundWorkerRunWorkerCompleted;

            string file_name = @"C:\Users\apersinger\Documents\Misc\jsonjobs.txt";
            string file_contents = util.OpenFile(file_name);
            if(file_contents.Length > 0) {
                data = util.DeserializeString(file_contents);
                mainJobList = new BindingList<IndeedDetails>(data);
                dataGridView1.DataSource = mainJobList;
            }

            txtURL.Text = "www.indeed.com";
            txtLocation.Text = "california";
            txtJobTitle.Text = "software";

            btnFilterResults.Enabled = false;
        }
开发者ID:persinac,项目名称:JobFinder,代码行数:28,代码来源:Form1.cs

示例9: PluginUpdaterForm

    public PluginUpdaterForm(PluginManager pluginManager)
      : base() {
      InitializeComponent();
      Text = "HeuristicLab Plugin Manager " + AssemblyHelpers.GetFileVersion(GetType().Assembly);
      pluginManager.PluginLoaded += pluginManager_PluginLoaded;
      pluginManager.PluginUnloaded += pluginManager_PluginUnloaded;
      pluginManager.Initializing += pluginManager_Initializing;
      pluginManager.Initialized += pluginManager_Initialized;

      pluginDir = Application.StartupPath;

      installationManager = new InstallationManager(pluginDir);
      installationManager.PluginInstalled += new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginInstalled);
      installationManager.PluginRemoved += new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginRemoved);
      installationManager.PluginUpdated += new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginUpdated);
      installationManager.PreInstallPlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreInstallPlugin);
      installationManager.PreRemovePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreRemovePlugin);
      installationManager.PreUpdatePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreUpdatePlugin);

      this.pluginManager = pluginManager;

      updatePluginsBackgroundWorker = new BackgroundWorker();
      updatePluginsBackgroundWorker.DoWork += new DoWorkEventHandler(updatePluginsBackgroundWorker_DoWork);
      updatePluginsBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(updatePluginsBackgroundWorker_RunWorkerCompleted);
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:25,代码来源:PluginUpdaterForm.cs

示例10: dooptimization

        public bool dooptimization()
        {
            initialcount = points.Count;
            currentpoint = 0;
            finishedthreads = 0;
            bws = new List<BackgroundWorker>();
            for(int i=0;i<100;i++)
            {
                bws.Add(new BackgroundWorker());
                            bws[i] = new BackgroundWorker
                {
                    WorkerReportsProgress = true,
                    WorkerSupportsCancellation = true
                };
                bws[i].DoWork += bw_DoWork;

                bws[i].RunWorkerCompleted += bw_RunWorkerCompleted;
                bws[i].RunWorkerAsync();//pass id???, what else?

            }
            while (finishedthreads!=100)
            {

            }
                return true;
        }
开发者ID:peterlvilim,项目名称:ShippingManager,代码行数:26,代码来源:Mapquest_Matrix.cs

示例11: b_open_Click

        private void b_open_Click(object sender_, RoutedEventArgs e_)
        {
            p_progress.Visibility = Visibility.Visible;
            p_label.Visibility = Visibility.Visible;

            bw_LoadFile = new BackgroundWorker();
            bw_LoadFile.DoWork += (sender, e) =>
            {
                LCIO.OpenFile(bw_LoadFile);
            };
            bw_LoadFile.ProgressChanged += (sender, e) =>
            {
                p_label.Content = e.UserState;
            };
            bw_LoadFile.RunWorkerCompleted += (sender, e) =>
            {
                if (e.Error != null)
                {
                    new TextMessage("Ошибка", e.Error.Message).ShowDialog();
                }
                p_progress.Visibility = Visibility.Hidden;
                p_label.Visibility = Visibility.Hidden;
                FLYOUT_OpenFile.IsOpen = false;
                UpdateList();
            };
            bw_LoadFile.WorkerReportsProgress = true;
            bw_LoadFile.RunWorkerAsync();
        }
开发者ID:RomeoST,项目名称:ItemAll,代码行数:28,代码来源:MainWindow.xaml.cs

示例12: Lobby

        public Lobby(Menu parent)
        {
            InitializeComponent();

            ImageBrush myBrush = new ImageBrush();
            myBrush.ImageSource = new BitmapImage(new Uri(".\\Resources\\icon_backarrow.png", UriKind.Relative));
            bekk.Background = myBrush;

            ImageBrush myBrush2 = new ImageBrush();
            myBrush2.ImageSource = new BitmapImage(new Uri(".\\Resources\\icon_closebutton.png", UriKind.Relative));
            klóz.Background = myBrush2;

            this.parent = parent;

            chatbox.Items.Clear();

            refreshworker = new BackgroundWorker();
            refreshworker.WorkerSupportsCancellation = true;
            refreshworker.WorkerReportsProgress = true;
            refreshworker.DoWork += refresh;
            refreshworker.ProgressChanged += refreshUI;

            activityworker = new BackgroundWorker();
            activityworker.WorkerSupportsCancellation = true;
            activityworker.DoWork += wait;
            activityworker.RunWorkerCompleted += doActivity;
        }
开发者ID:BlackRebels,项目名称:IQ-Champions,代码行数:27,代码来源:Lobby.xaml.cs

示例13: AtmosphereControl

        public AtmosphereControl( )
        {
            InitializeComponent( );

            //	Populate texture resolution combo boxes
            for ( int i = 4; i <= 1024; i *= 2 )
            {
                resolutionComboBox.Items.Add( i );
            }
            resolutionComboBox.SelectedItem = m_AtmosphereBuildParameters.HeightSamples;

            m_AtmosphereBuilder = new AtmosphereBuilder( );

            mH0UpDown.Value = ( decimal )m_AtmosphereModel.MieDensityScaleHeightFraction;
            rH0UpDown.Value = ( decimal )m_AtmosphereModel.RayleighDensityScaleHeightFraction;
            //	TODO: AP: Remove bodges
            inscatterDistanceFudgeUpDown.Value = ( decimal )m_AtmosphereModel.InscatterDistanceFudgeFactor;
            outscatterDistanceFudgeUpDown.Value = ( decimal )m_AtmosphereModel.OutscatterDistanceFudgeFactor;
            outscatterFudgeUpDown.Value = ( decimal )m_AtmosphereModel.OutscatterFudgeFactor;
            mieFudgeUpDown.Value = ( decimal )m_AtmosphereModel.MieFudgeFactor;
            rayleighFudgeUpDown.Value = ( decimal )m_AtmosphereModel.RayleighFudgeFactor;

            m_Worker = new BackgroundWorker( );
            m_Worker.WorkerReportsProgress = true;
            m_Worker.WorkerSupportsCancellation = true;
            m_Worker.DoWork += BuildWorkItem;
            m_Worker.RunWorkerCompleted += WorkItemComplete;
            m_Worker.ProgressChanged += BuildProgressChanged;
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:29,代码来源:AtmosphereControl.cs

示例14: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     BackgroundWorker worker = new BackgroundWorker();
     DataLocation loc = (DataLocation)ComboBoxSearchLocation.SelectedIndex;
     worker.DoWork += (s, args) =>
     {
         try
         {
             Data.Letter[] LettersControl = null;
             DateType _dType = DateType.All;
             if (!CalendarAllCheckBox.Checked)
                 _dType = (DateType)ComboBoxDate.SelectedIndex + 1;
             LettersControl = DBase.DataBase.GetLetters(TXTNumber.GetValue(), ComboProviders.Text, ComboTypes.Text, TXTFrom.Text, TXTTo.Text, TXTMoney.Text, TXTMoney2.Text, ComboUser.SelectedItem.ToString(), TextInc.Text, _dType, DateFrom.Value, DateTo.Value, loc);
             args.Result = LettersControl;
         }
         catch { args.Result = null; }
     };
     worker.RunWorkerCompleted += (s, args) =>
     {
         if (args.Result == null) return;
         AddLetters(args.Result as Data.Letter[]);
         (this.ParentForm as Form1).WaitDisable();
     };
     (this.ParentForm as Form1).WaitEnable();
     worker.RunWorkerAsync();
 }
开发者ID:vaso991,项目名称:Document-Manager,代码行数:26,代码来源:LettersControl.cs

示例15: MakeDatZips

        public static void MakeDatZips(object sender, DoWorkEventArgs e)
        {
            _bgw = sender as BackgroundWorker;
            Program.SyncCont = e.Argument as SynchronizationContext;
            if (Program.SyncCont == null)
            {
                _bgw = null;
                return;
            }

            if (!Directory.Exists(_outputdir))
                return;

            if (_treeRow != null)
                FindDats(_treeRow);
            else
            {
                RvGame tGame = new RvGame();
                tGame.DBRead((int)_gameId, true);
                ExtractGame(tGame, _outputdir);
            }
            _bgw.ReportProgress(0, new bgwText("Creating Zips Complete"));
            _bgw = null;
            Program.SyncCont = null;
        }
开发者ID:thatswork,项目名称:RomVaultX,代码行数:25,代码来源:ReMakeZips.cs


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