backgroundworker

“BindingSource cannot be its own data source” - error when trying to reset the binding source from a method in another class

六眼飞鱼酱① 提交于 2020-01-11 05:06:30
问题 We are binding a DataGridview using BindingSource . So in the main thread we have given like this. class1BindingSource = new BindingSource(); class1BindingSource.DataSource = class1List; this.dataGridView1.DataSource = class1BindingSource; After that i have a placed a background worker in the form and is triggering in a button click. i.e. in the button click this.backgroundWorker1.RunWorkerAsync() In the BackgroundWorker DoWork Event i am trying to update the BindingSource and there by trying

Send a backgroundworker to sleep while checking for cancellation

五迷三道 提交于 2020-01-11 03:11:06
问题 I have a background worker which updates the GUI on a regular basis via ReportProgress. The update occurs at regular intervals, every 5 seconds for example, or it could be 20 seconds. In order to perform the update at set times I send the worker process to sleep for the duration and when it wakes it updates the GUI with new information. The worker supports cancellation, and outside of sleeping it cancels correctly. I want to be able to invoke the cancellation during the wait period, however

BackgroundWorker WPF difficulties with Progress Bar

我怕爱的太早我们不能终老 提交于 2020-01-10 04:35:07
问题 I am developing a WPF, C# application and I have to read a very big CSV file and write to a database. This process takes a long time so I want to at least show a progress bar that grows in size as it nears completition. Now, I have the following code at the top: private readonly BackgroundWorker worker = new BackgroundWorker(); Then inside the loop I have this: worker.WorkerReportsProgress = true; worker.ReportProgress((100 * i) / 10000); and I have a private sub like this: private void

VB.NET Delegates and Invoke - can somebody explain these to me?

大憨熊 提交于 2020-01-09 09:38:36
问题 I'm new to the world of threading, but a few aspects of an app I'm working on require me to use a BackgroundWorker control to prevent the UI freezing up while it's doing some file operations. What I'm trying to do is update a couple of form labels from within the BackgroundWorker. Having never worked with this before I very quickly discovered that I can't access controls that weren't created within the same thread, so after a bit of research I've implemented the following code that seems to

VB.NET Delegates and Invoke - can somebody explain these to me?

人盡茶涼 提交于 2020-01-09 09:38:12
问题 I'm new to the world of threading, but a few aspects of an app I'm working on require me to use a BackgroundWorker control to prevent the UI freezing up while it's doing some file operations. What I'm trying to do is update a couple of form labels from within the BackgroundWorker. Having never worked with this before I very quickly discovered that I can't access controls that weren't created within the same thread, so after a bit of research I've implemented the following code that seems to

WPF mvvm backgroundWorker busyIndicator

僤鯓⒐⒋嵵緔 提交于 2020-01-07 06:47:09
问题 I'm using the busyIndicator in my program that works with MVVM pattern, I found out that there is a problem with background worker and dealing with objects that are binded in the view so I used the Dispacher.Invoke method on all of the functions that use binded properties, after I used the Dispacher the busyIndicator showed up, but when the backgoundWorker finished my view had no elements inside, what am I doing wrong? I know it's a little low in code but i didn't know what (and if) will help

Does it mean that Invoke() method has to be called on each UI control?

耗尽温柔 提交于 2020-01-06 13:27:07
问题 Following is a method that does Insert into the database table. And I am calling this method within DoWork() of BackGroundWorker thread. It obviously throws me the "cross thread operation not valid..." error. As I understand, I could use Invoke() method on UI controls if those to be accessed within DoWork() . BUT does it mean each of the following UI controls should have to be invoked ? Is there a better way to achieve this? private void AddToOccupations() { if (dataGridViewSearch

Updating a status on a Winform in BackgroundWorker

房东的猫 提交于 2020-01-06 08:41:52
问题 I have a multi-step BackgroundWorker process. I use a marquee progress bar because several of these steps are run on a iSeries server so there isn't any good way to determine a percentage. What I am envisioning is a label with updates after every step. How would you recommend updating a label on a winform to reflect each step? Figured I would add a bit more. I call some CL and RPG programs via a stored procedure on an iSeries (or IBM i or AS/400 or a midrange computer running OS/400... er...

multiple backgroundworker queueing

我与影子孤独终老i 提交于 2020-01-04 09:23:34
问题 in my winforms app, I have a Queue which contains objects: Queue<MyObj> _queuedRows = new Queue<MyObj>(); For each object, I must start a separate backgroundworker to do some timeconsuming job. private void DoAll(List<MyObj> lst) { foreach (MyObj o in lst) { _queuedRows.Enqueue(o); } while (_queuedRows.Any()) DoSingle(); } private void DoSingle() { if (!isCancelPending()) { if (_queuedRows.Any()) { MyObj currentObj = _queuedRows.Dequeue(); InitBackgroundWorker(currentObj); } } } private void

Value of volatile variable doesn't change in multi-thread

自闭症网瘾萝莉.ら 提交于 2020-01-04 03:57:26
问题 I have a winform application that runs in background with a BackgroundWorker that has an infinite loop that execute something every hour. My UI Form class is something like this: public partial class frmAutoScript : Form { private volatile bool _isDownloading = false; private bool IsDownloading { get { return this._isDownloading; } set { this._isDownloading = value; } } public frmAutoScript() { InitializeComponent(); this.RunAutoSynchronization(); } private void RunAutoSynchronization() {