backgroundworker

Update label text in background worker winforms

做~自己de王妃 提交于 2019-11-27 05:51:58
问题 I am using BackGroundWorker class to insert some values in sqlserver. I have for loop here to insert values. i am using following code public void bw_Convert_DoWork(object sender, DoWorkEventArgs e) { e.Result = e.Argument; for (int i = 0; i < fTable.Rows.Count; i++) { try { SqlCommand cmd = new SqlCommand("INSERT INTO TBL_CDR_ANALYZER (LNG_UPLOAD_ID, DAT_START, LNG_DURATION, INT_DIRECTION, INT_CALL_DATA_TYPE, \n" + "TXT_TARGET_NUMBER, TXT_OTHER_PARTY_NUMBER, TXT_TARGET_IMSI, TXT_TARGET_IMEI,

C# Winform ProgressBar and BackgroundWorker

泪湿孤枕 提交于 2019-11-27 05:24:41
I have the following problem: I have a Form named MainForm. I have a long operation to be taken place on this form. While this long operation is going on, I need to show another from named ProgressForm on top of the MainForm. ProgressForm contains a progress bar which needs to be updated while the long operation is taking place. After the long operation is completed, the ProgressForm should be closed automatically. I have written the following code: using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Threading; namespace ClassLibrary {

Using the .NET BackgroundWorker from VB6 fails with an AccessViolationException

痞子三分冷 提交于 2019-11-27 04:48:38
问题 The following MSDN example promises to demonstrate how to use the .NET BackgroundWorker from VB6 but it fails with an AccessViolationException. The only workaround is to compile the VB6 code as P-code, but that is not a viable option for us. http://msdn.microsoft.com/en-us/library/aa719109(VS.71).aspx Here are lots of details of the problem. objectmix.com/dotnet/331152-using-background-threads-visual-basic-6-accessviolationexcep.html How can I fix the example to work without compiling the VB6

InvalidOperationException - object is currently in use elsewhere

泄露秘密 提交于 2019-11-27 04:46:53
I've gone through this SO question but it didn't help. The case here is different. I'm using Backgroundworkers. 1st backgroundworker starts operating on the image input of user and inside firstbackgroundworker_runworkercompleted() I'm using calling 3 other backgroundworkers algo1backgroundworker.RunWorkerAsync(); algo2backgroundworker.RunWorkerAsync(); algo3backgroundworker.RunWorkerAsync(); this is the code for each: algo1backgroundworker_DoWork() { Image img = this.picturebox.Image; imgclone = img.clone(); //operate on imgclone and output it } algo2backgroundworker_DoWork() { Image img =

Can you link to a good example of using BackgroundWorker without placing it on a form as a component?

↘锁芯ラ 提交于 2019-11-27 04:33:31
I can remember that many years ago (in 2005) I was using BackgroundWorker in my code without using a visual component for it, but I can't remember how (unfortunately I am very forgetful and forget everything very soon after I stop using it). Perhaps I was extending BackgroundWorker class. Can you link to a good example of using BackgroundWorker this way? CharithJ This article explains everything you need clearly. Here are the minimum steps in using BackgroundWorker: Instantiate BackgroundWorker and handle the DoWork event. Call RunWorkerAsync, optionally with an object argument. This then sets

How to cancel a long-running Database operation?

落花浮王杯 提交于 2019-11-27 03:57:46
Currently working with Oracle, but will also need a solution for MS SQL. I have a GUI that allows users to generate SQL that will be executed on the database. This can take a very long time, depending on the search they generate. I want the GUI/App to responsive during this search and I want the user to be able to cancel the search. I'm using a Background Worker Thread. My problem is that, when the user cancels the search, I can't interrupt the call to the database. It waits until it is finished and then, it can poll the 'CancelationPending' property. Not only does this waste resources on the

How to report progress from within a class to a BackgroundWorker?

淺唱寂寞╮ 提交于 2019-11-27 02:15:47
问题 My WinForm calls a class which performs some copying actions. I'd like to show the progress of this on a form. I'd like to use the Backgroundworker, but I don't know how to report progress from the class to the form (/backgroundworker) 回答1: use the OnProgressChanged() method of the BackgroundWorker to report progress and subscribe to the ProgessChangedEvent of the BackgroundWorker to update the progress in your GUI. Your copy class knows the BackgroundWorker and subscribes to ProgressChanged

Proper way to Dispose of a BackGroundWorker

空扰寡人 提交于 2019-11-27 01:47:38
Would this be a proper way to dispose of a BackGroundWorker? I'm not sure if it is necesary to remove the events before calling .Dispose(). Also is calling .Dispose() inside the RunWorkerCompleted delegate ok to do? public void RunProcessAsync(DateTime dumpDate) { BackgroundWorker worker = new BackgroundWorker(); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerAsync(dumpDate); } void worker_DoWork(object sender, DoWorkEventArgs e) { // Do Work here } void worker

Long-running computations in node.js

若如初见. 提交于 2019-11-27 01:02:47
问题 I'm writing a game server in node.js, and some operations involve heavy computation on part of the server. I don't want to stop accepting connections while I run those computations -- how can I run them in the background when node.js doesn't support threads? 回答1: I can't vouch for either of these, personally, but if you're hell-bent on doing the work in-process, there have been a couple of independent implementations of the WebWorkers API for node, as listed on the node modules page: http:/

This BackgroundWorker is currently busy and cannot run multiple tasks concurrently

拜拜、爱过 提交于 2019-11-27 00:50:51
问题 I get this error if I click a button that starts the backgroundworker twice. This BackgroundWorker is currently busy and cannot run multiple tasks concurrently How can I avoid this? 回答1: Simple: Don't start the BackgroundWorker twice. You can check if it is already running by using the IsBusy property, so just change this code: worker.RunWorkerAsync(); to this: if( !worker.IsBusy ) worker.RunWorkerAsync(); else MessageBox.Show("Can't run the worker twice!"); Update: If you do actually need to