backgroundworker

How to wait and get text from another form in multiple backgroundworker

霸气de小男生 提交于 2019-12-11 15:24:51
问题 This is Form1 public static BackgroundWorker[] threadArray; //public static AutoResetEvent[] _eventHandles ; public static readonly object _lockObj = new object(); public static bool _go ; //public static ManualResetEvent _manualResetEvent = new ManualResetEvent(false); private void BackgroundWorkerFilesDoWork(object sender, DoWorkEventArgs e) { ... lock (_lockObj) { //_manualResetEvent.WaitOne(30000); //_manualResetEvent.Reset(); //if (clsValueStatic.CaptchaText != null) //{ // foreach (var

BackgroundWorker and Progressbar.Show()

限于喜欢 提交于 2019-12-11 14:05:03
问题 I am using Visual Studio 2010 and C# and try to get my progressbar to show but it doesn't work. I listen to an event. If it happens I want to do some work and show a progressbar while doing that. This is what I do: static void Main(string[] args) { ProgressForm form = new ProgressForm(); new FileWatcher(form).Start(); Application.Run(); } ProgressForm: bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork); private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { this.Show(); ....

Report progress inside for loop

早过忘川 提交于 2019-12-11 13:47:24
问题 I am calling this code inside a for loop and I need to do this since progress depends on this for loop value. bgworker1.ReportProgress(k * count); But I receive an exception: this operation has already had operation completed called on it and further calls are illegal How can I solve this?? Edit: private void bgworker1_DoWork(object sender, DoWorkEventArgs e) { for (k = 1; k <= tcount; k++) { bgworker1.ReportProgress(k * count); } } private void bgworker1_ProgressChanged(object sender,

Creating FlowDocument on BackgroundWorker thread

和自甴很熟 提交于 2019-12-11 12:59:22
问题 I have the need to generate dynamically generate a FlowDocument from a large set of data. Because the process takes several minutes, I'd like to perform the operation on a background thread rather than have the UI hang. However, I can't generate the FlowDocument on a non-UI thread otherwise attempts to insert rectangles and images cause run-time errors complaining that it's not STA thread. There are a couple of threads on StackOverflow which seem to involve the same problem I'm having:

How do I access the local storage using service workers in angular?

廉价感情. 提交于 2019-12-11 12:52:10
问题 Okay now i am working on Angular 6 webApp and it is offline first. I am able to setup a fully functional service worker which can retrieve and store requests and response and what not. But, at one point , while registering a sync event, i needed refresh tokens which are stored in the local storage of my webApp. The problem is that service workers are not allowed to access local storage directly, means i don't have any access to the tokens residing in the local storage.How can i make use of

How to change textbox.text while in backgroundworker?

喜欢而已 提交于 2019-12-11 12:36:14
问题 I just want to change an textbox text while I am in the backgroundworker. What I have is: Private Sub ... Dim powershellWorker As New BackgroundWorker AddHandler powershellWorker.DoWork, AddressOf BackgroundWorker1_DoWork powershellWorker.RunWorkerAsync() End Sub Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork If stuff <> "lol" Then test.Text = stuff End Sub It gives me the error: "Invalid

How to implement Pause & Resume functionality with BackgroundWorker c#

左心房为你撑大大i 提交于 2019-12-11 11:23:52
问题 i want to implement pause resume and cancel functionality with BackgroundWorker. i have a one user control and all backgroundworker related code written in user control. i just add user control on flow layout control as many as time user click on buttons. i am fail to impelement Pause & Resume functionality with ManualResetEvent but anyway i am not being able to do it. so here i am pasting my user control class related code and my form code. public partial class ucBackgroundWorker :

C# updating backgroundworker progress from separate class

早过忘川 提交于 2019-12-11 11:05:35
问题 I am trying to run a function in a different class than the dispatcher through a backgroundworker and have it update the progress on every iteration. I am getting no errors and the backgroundworker is functioning properly, but my textbox never updates... public partial class MainWindow : Window { public BackgroundWorker worker = new BackgroundWorker(); public MainWindow() { InitializeComponent(); worker.WorkerReportsProgress = true; worker.DoWork += new DoWorkEventHandler(workerDoWork);

BackgroundWorker & Progressbar Issues c# Visual Studio 2010

左心房为你撑大大i 提交于 2019-12-11 10:57:06
问题 Im trying to get my head around backgroundworker and the progressbar, so far i have got it to work but not exactly how i want it to work. Basically i am sorting/renaming folders and copying them to a different location, this works and the code is self explanatory, the output folders generated are as expected. However for each folder i intend to search through i have to right click it to get the number of files and then in the code i have to set the progressBar1.Maximum to that value in order

C# BackGroundWorker Anomaly DoWork event not firing

与世无争的帅哥 提交于 2019-12-11 10:52:22
问题 This is the setup I have, this code works properly private void butGo_Click(object sender, EventArgs e) { threadCreateImages.RunWorkerAsync(); } private void threadCreateImages_DoWork(object sender, DoWorkEventArgs e) { PatientToHL7MSHManager tvPatientToHL7MSHManager = new PatientToHL7MSHManager(); tvPatientToHL7MSHManager.LoadByMSHID(""); } private void threadCreateImages_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { MessageBox.Show("DONE"); } if I change this line