backgroundworker

Displaying wait cursor in while backgroundworker is running

爷,独闯天下 提交于 2019-11-30 06:39:51
During the start of my windows application, I have to make a call to a web service to retrieve some default data to load onto my application. During the load of the form, I run a backgroundworker to retrieve this data. I want to display the wait cursor until this data is retrieved. How would I do this? I've tried setting the wait cursor before calling the backgroundworker to run. When I report a progress of 100 then I set it back to the default cursor. The wait cursor comes up but when I move the mouse it disappears. Environment: Windows 7 Pro 64-bit VS2010 C# .NET 4.0 Windows Forms EDIT: I am

Backgroundworker processing in own class

▼魔方 西西 提交于 2019-11-30 05:30:55
问题 Well, I have the following problem and I hope that you can help me: I would like to create a WPF application with a background worker for updating richtextboxes and other UI elements. This background worker should process some data, e.g. handle the content of a folder, do some parsing and much more. Since I would like to move as much code as possible outside the Main class, I created a class called MyProcess.cs as you can see below (in fact, this class does not make much sense so far, it will

BackgroundWorker & Timer, reading only new lines of a log file?

限于喜欢 提交于 2019-11-30 05:10:44
My application writes a log file (currently using log4net ). I'd like to setup a timer and a background worker to read the log file and print its content into some control in my form, while it's being written. I can't use the FileSystemWatcher class because seems broken: sometimes the event "changed" fires, sometimes do not. And it has an extremely low "pooling rate". So I created a Timer and a FileSystemWatcher. On the "tick" event of the timer, the background worker does its job. The question is: how to read only the lines that are added since the last check of the worker? public LogForm() {

reusing the backgroundworker more than once

假装没事ソ 提交于 2019-11-30 05:07:46
问题 i am using the background worker to do an expensive operation: backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted); backgroundWorker1.RunWorkerAsync(inputs); At the end i have this: void backgroundWorker1_RunWorkerCompleted(object sender,

What does Cannot modify the logical children for this node at this time because a tree walk is in progress mean?

自古美人都是妖i 提交于 2019-11-30 04:47:31
I am setting the DataContext of an object in the completed method of a background worker thread. For some reason, I get an error saying: Cannot modify the logical children for this node at this time because a tree walk is in progress pointing to the Chart1.DataContext=allDates line. What does a tree walk is in progress mean? I've tried doing this set using a Dispatcher operation as well and that gives the same error... Any ideas? Google yeilds nothing on this error message. The code taht's causing this is internal to Microsoft's Charting toolkit... I wonder if I've found a bug in their control

.NET Backgroundworker Object's Thread Priority

杀马特。学长 韩版系。学妹 提交于 2019-11-30 04:01:05
I am trying to use the .NET Backgroundworker Object in an application I am developing. All the material on the internet say that this object runs in the "background" but nowhere have I been able to confirm that this background thread indeed runs in a "low priority" mode . This question arises because in Windows (I assume) a background task can run in a 'normal' or 'below normal' or 'low' priority mode. In my application, I tried to set the priority myself inside the DoWork function by calling ... Thread.CurrentThread.Priority=ThreadPriority.Lowest ... but this seems to have no effect. Does the

Refresh UI with a Timer in WPF (with BackgroundWorker?)

爷,独闯天下 提交于 2019-11-30 02:17:26
问题 We have an application in WPF that shows data via ObservableCollection. After 5 minutes, I want to refresh the data. I thought I could use the System.Timers.Timer object for its Elapsed event and then call a BackgroundWorker to call the method that starts the job. The method is on a ViewModel class. But it seems that there's a problem the threads. So I tried with the Dispatcher, but same thing again. Here's my (simplified and not optimized) code : /// <summary> /// Initializes a new instance

Wasn't it .NET 4.0 TPL that made APM, EAP and BackgroundWorker asynchronous patterns obsolete?

无人久伴 提交于 2019-11-29 22:25:24
I have 2 kinds of C# WPF app projects: based on .NET 4.0 that I cannot migrate to .NET 4.5 based on .NET 4.0 that I can migrate to .NET 4.5 All of them should spawn 2-10 long-running (days) processes which can be cancelled and re-launched by users. I am interested to follow the best design practices. First of all, now, I am interested to disambiguate about BackgroundWorker usage though, I hope, my question should be valid about other asynchronous patterns. I see (contradicting) concurrent points of view about Asynchronous Programming Model (APM) Event-based Asynchronous Pattern (EAP)

C# Can I add values to a listbox with a backgroundwork thread?

拟墨画扇 提交于 2019-11-29 20:51:24
问题 I want my background worker to add items to a list box, it appears to do so when debugging but the listbox doesn't show the values. I suspect this is something to do with adding items whilst inside the background worker thread, do I need to add these to an array and then populate the list box from the array during backgroundWorker1_RunWorkerCompleted ? Thanks for the help. 回答1: You can use Invoke like this: private void AddToListBox(object oo) { Invoke(new MethodInvoker( delegate { listBox

Popping a MessageBox for the main app with Backgroundworker in WPF

最后都变了- 提交于 2019-11-29 19:23:52
问题 In a WPF app, I am using a BackgroundWorker to periodically check for a condition on the server. While that works fine, I want to pop a MessageBox notifing the users if something fails during the check. Here's what I have: public static void StartWorker() { worker = new BackgroundWorker(); worker.DoWork += DoSomeWork; worker.RunWorkerAsync(); } private static void DoSomeWork(object sender, DoWorkEventArgs e) { while (!worker.CancellationPending) { Thread.Sleep(5000); var isOkay =