backgroundworker

VB.NET progressbar backgroundworker

痞子三分冷 提交于 2019-11-26 08:28:10
问题 When my application starts, and it has just been upgraded, I am doing a local database update (sqlite). It is like that: The user starts my app, and then I start the upgrade process. During this upgrade process I am showing a form that has a continuous progressbar. This form closes when the upgrade process is done and the user can then start using my application. But the progressbar won\'t animate since the upgrade process is so intensive. In my old VB6 version I used an ActiveX-Exe that has

File Copy with Progress Bar

我的梦境 提交于 2019-11-26 08:07:16
问题 I used this code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.IO; namespace WindowsApplication1 { public partial class Form1 : Form { // Class to report progress private class UIProgress { public UIProgress(string name_, long bytes_, long maxbytes_) { name = name_; bytes = bytes_; maxbytes = maxbytes_; } public string name; public long bytes; public long maxbytes; } // Class to report exception { private class UIError {

How can I make a background worker thread set to Single Thread Apartment?

ⅰ亾dé卋堺 提交于 2019-11-26 06:47:01
问题 I am creating an automated test running application. In this part of the application, I am working on a polling server. It works by constantly polling the web server to determine when a new automated test should be run (for nightly automated runs of our GUI application). When the polling server sees a request, it downloads all the information necessary and then executes the test run in a background worker. The problem is that part of the test run has OLE, COM, and other calls (for example,

Unhandled exceptions in BackgroundWorker

旧时模样 提交于 2019-11-26 06:27:30
问题 My WinForms app uses a number of BackgroundWorker objects to retrieve information from a database. I\'m using BackgroundWorker because it allows the UI to remain unblocked during long-running database queries and it simplifies the threading model for me. I\'m getting occasional DatabaseExceptions in some of these background threads, and I have witnessed at least one of these exceptions in a worker thread while debugging. I\'m fairly confident these exceptions are timeouts which I suppose its

How to “kill” background worker completely?

别来无恙 提交于 2019-11-26 04:39:06
问题 I am writing a windows application that runs a sequence of digital IO actions repeatedly. This sequence of actions starts when the user click a \"START\" button, and it is done by a background worker in backgroundWorker1_DoWork(). However, there are occasions when I get the \"This backgroundworker is currently busy.......\" error message. I am thinking of implementing the following in the code, by using a while loop to \"kill\" the background worker before starting another sequence of action:

How to stop BackgroundWorker correctly

拟墨画扇 提交于 2019-11-26 03:57:37
问题 I have a form with 2 comboboxes on it. And I want to fill combobox2.DataSource based on combobox1.Text and combobox2.Text (I assume that the user has completed input in combobox1 and is in the middle of inputting in combobox2 ). So I have an event handler for combobox2 like this: private void combobox2_TextChanged(object sender, EventArgs e) { if (cmbDataSourceExtractor.IsBusy) cmbDataSourceExtractor.CancelAsync(); var filledComboboxValues = new FilledComboboxValues{ V1 = combobox1.Text, V2 =

How to correctly implement a BackgroundWorker with ProgressBar updates?

谁都会走 提交于 2019-11-26 03:22:41
问题 -Updated--14/10 also asked this question To give some clear idea of what is going on and taking into account the comments and from this article here What I really want to do now is invoke a new form with a progress bar on it and have that run and animate whilst my back ground thread runs my long process to the database and then invoke a close form event The background worker is set up here public partial class MainWindow : Window { //Declare background workers BackgroundWorker bw = new

Sending Arguments To Background Worker?

会有一股神秘感。 提交于 2019-11-26 03:06:16
问题 Let\'s say I want to sent an int parameter to a background worker, how can this be accomplished? private void worker_DoWork(object sender, DoWorkEventArgs e) { } I know when this is worker.RunWorkerAsync();, I don\'t understand how to define in worker_DoWork that it should take an int parameter. 回答1: You start it like this: int value = 123; bgw1.RunWorkerAsync(argument: value); // the int will be boxed and then private void worker_DoWork(object sender, DoWorkEventArgs e) { int value = (int) e

BackgroundWorker RunWorkerCompleted Event

匆匆过客 提交于 2019-11-26 02:12:53
问题 My C# application has several background workers. Sometimes one background worker will fire off another. When the first background worker completes and the RunWorkerCompleted event is fired, on which thread will that event fire, the UI or the first background worker from which RunWorkerAsync was called? I am using Microsoft Visual C# 2008 Express Edition. Any thoughts or suggestions you may have would be appreciated. Thanks. 回答1: If the BackgroundWorker was created from the UI thread, then

Async/await vs BackgroundWorker

旧街凉风 提交于 2019-11-26 01:56:24
问题 In the past few days I have tested the new features of .net 4.5 and c# 5. I like its new async/await features. Earlier I had used BackgroundWorker to handle longer processes in the background with responsive UI. My question is: after having these nice new features, when should I use async/await and when a BackgroundWorker? Which are the common scenarios for both? 回答1: async/await is designed to replace constructs such as the BackgroundWorker . While you certainly can use it if you want to,