backgroundworker

Updating an Image UI property from a BackgroundWorker thread

独自空忆成欢 提交于 2019-12-06 11:31:50
问题 In a WPF application I'm writing, I have a TransformedBitmap property which is bound to an Image object on the UI. Whenever I change this property, the Image is updated (and thus the image being displayed to the screen is updated). In order to prevent the UI from freezing or becoming unresponsive whilst I retrieve the next image, I'm attempting to the snapshot retrieval with a BackgroundWorker like this: private void bw_DoWork(object sender, DoWorkEventArgs e) { e.Result = this.snapshotHelper

c# Background worker class

北城以北 提交于 2019-12-06 11:22:55
I want to put this method into background worker class, i am trying but stuck, can any one help me how to run this method into background worker class: I am calling this method into my asp.net page, where file are zipped on server and then returend to the client. but zipping of file may take longer and user will see a busy screen, so to avoid that i want to use background worker class: [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)] public string Zip(string f, bool original) { string zip = ""; try { files = HttpContext.Current.Server.UrlDecode(files); string[] fileCollection =

Thread not run immediately when using more than 4 BackgroundWorker

删除回忆录丶 提交于 2019-12-06 10:41:51
I use multiple BackgroundWorker control to run some task as multithreading. But I found that when using more than 4 BackgroundWoker, the one from 4th forward delay more than second to actually execute from when calling RunWorkerAsync . Could help me how can I start all backgroundworker immediately? class TaskLog { public int task_id; public DateTime call_time; public DateTime start_time; public DateTime end_time; } BackgroundWorker[] bws = new BackgroundWorker[18]; int[] tasks = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; Queue<TaskLog> queueTask; TaskLog[] records; int task_complete = 999;

C# BackGroundWorker with ProgressBar Updates after process complete

 ̄綄美尐妖づ 提交于 2019-12-06 09:08:33
I have the following in a button click event: private void buttonSubmitAchChecks_Click(object sender, EventArgs e) { if (backgroundWorker1.IsBusy) return; SubmittingAch(true); backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = true; label_Status.Text = "Submitting checks to ACH ...."; var qry = from ds in checkTrans.IndividualCheck where ds.SubmitToACH && ds.Status == "Entered" && ds.CheckAmount > 0 && ds.SubmitToACH select ds; if (qry.Count() <= 0) { label_Status.Text = "Nothing to submit. Check the Check Amount, ACH, and Status fields."; } else {

detecting usb-device insertion and removal in c#

陌路散爱 提交于 2019-12-06 08:13:19
问题 i tried one of the solutions in this thread Detecting USB drive insertion and removal using windows service and c#. but i stil get errors, because of the thread-unsafe call to windows forms control. here is my code private void initWatchers() { WqlEventQuery insertQuery = new WqlEventQuery("SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_USBHub'"); ManagementEventWatcher insertWatcher = new ManagementEventWatcher(insertQuery); insertWatcher.EventArrived += new

How to put this function inside a separate thread

旧街凉风 提交于 2019-12-06 07:37:41
I need a little (or big) help with my form: I need to use everything inside the "Organize function" region in a separate thread. I press a button in my form's "Start button" region to call the first sub of the "Organize function" subs; the first sub calls the second sub and the second sub calls the third sub. I tried adding the third sub into a separate thread by myself and then using the second sub to pass the argument to the thread but all I've done is wrong. Can someone please help me do this? PS: I've deleted the non-important parts in this form to let you check better. Thank you for

How do I update the progress bar one step, every loop cycle? C#

余生长醉 提交于 2019-12-06 07:15:42
问题 Creating a .net application in C#, windows forms. How do I update the progress bar 1 step every cycle of a 100 cycle loop? (I’m processing an excel sheet in the loop.) The progress bar controls are in the UI class which connects to the controller class which connects to a custom class (MVC pattern). The loop is in the custom class. Do I need to send the UI class instance all the way down in each method or is there a better way? Right now the progress bar updates after the loop finishes.

How to use BackGroundWorker in class file?

女生的网名这么多〃 提交于 2019-12-06 06:08:34
问题 My program.cs calls the mdi parent frmMain. frmMain then opens different child forms based on user action. All the processing logic is written in BusinessLogic.cs. frmMain at load calls the methods of BusinessLogic.cs to initially populate the data. The child forms too call BusinessLogic to fetch data and process it. I'd like to do all this through a BackGroundWorker ie the frmMain calls the (say) StartBGWorker() method of BusinessLogic.cs and this method creates a backgroundworker for this

C# using a timer inside a Backgroundworker

血红的双手。 提交于 2019-12-06 04:40:20
I couldn't find a solution for this yet...hope someone can help me. I have a backgroundworker that runs until it is cancelled by the user (it reads data from a socket and writes it into a file). Now I want to split the output file after a certain period of time, e.g. every 2 mins create a new file. For this to happen I'd like to use a timer, something like private void bckWrkSocket_DoWork(object sender, DoWorkEventArgs e) { //create timer and set its interval to e.Argument //start timer while(true) { if(timer.finished == true) { //close old file and create new //restart timer } ... } } Any

Passing Values To and From Background Worker

安稳与你 提交于 2019-12-06 04:31:13
问题 I'm a self-taught novice experimenting with the Rijndael encryption algorithm, I've previously got it to work very well, but since trying to get the encryption to run on a background worker to free-up the the form for the user I've ran into numerous issues. Firstly I tried just placing the byval's I used in my previous code into the background worker, but I got an error with it not being compatible -- Specifically the ByVal Direction As CryptoAction . So to be clear, I was trying something