backgroundworker

Regularly report progress of a BackgroundWorker

こ雲淡風輕ζ 提交于 2021-02-11 09:47:38
问题 I'm writing a music player. This is the (early) code that adds a directory to the playlist: private void SelectFolderButton_Click(object sender, EventArgs e) { int count = 0; AddFolderDialog.ShowDialog(); if(AddFolderDialog.SelectedPath != string.Empty) { BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += (a,b) => playlist.AddFolder(AddFolderDialog.SelectedPath, RecursiveCheckBox.Checked, out count); bgw.RunWorkerAsync(); bgw.RunWorkerCompleted += (a, b) => mainStatusLabel.Text =

Waiting for UI re-rendering to complete

心已入冬 提交于 2021-02-10 18:34:13
问题 I've actually got 2 similar problems here with no luck finding anything on the web. Problem 1: Using a BackgroundWorker, I am updating the UI with the % done, but I am using the UserState because I want to report fraction of a percent. The problem is, depending on the inputs, sometimes updates happen rarely (a percent every couple seconds) and other times very fast (triggering fractional % updates many times a second). In the latter case, I'm getting a stack overflow (no pun intended) issue.

Waiting for UI re-rendering to complete

戏子无情 提交于 2021-02-10 18:33:37
问题 I've actually got 2 similar problems here with no luck finding anything on the web. Problem 1: Using a BackgroundWorker, I am updating the UI with the % done, but I am using the UserState because I want to report fraction of a percent. The problem is, depending on the inputs, sometimes updates happen rarely (a percent every couple seconds) and other times very fast (triggering fractional % updates many times a second). In the latter case, I'm getting a stack overflow (no pun intended) issue.

How do you pass a List<> of Lists<> to a background worker?

北城余情 提交于 2021-02-08 11:42:16
问题 I have a backgroundWorker that is processing two lists. I need to pass the Lists to the worker. the result is empty lists. Code to pass the Lists (and 2 other parameters). In my test, each list has 20+ items, and the List<> items show that the 20+ items are intact just prior to the call. In the inspector they say "Count" followed by the number of items. List<Object> arguments = new List<object>(); // Add arguments to pass to background worker arguments.Add(managerSource); arguments.Add

How do I change the rendered template in Flask when a thread completes?

不想你离开。 提交于 2021-02-07 08:47:34
问题 I have a function that crawls the web for data and computes a score for the search. However, this can take a while and sometimes the webpage times out before finishing execution. So I created a separate thread that executes the function and loading.html that tells the client that data is still being collected. Once the function ends in the thread, how do I reload the webpage to display output.html that displays the score. This is a simpler version of what I have so far: from flask import

How do I change the rendered template in Flask when a thread completes?

↘锁芯ラ 提交于 2021-02-07 08:46:12
问题 I have a function that crawls the web for data and computes a score for the search. However, this can take a while and sometimes the webpage times out before finishing execution. So I created a separate thread that executes the function and loading.html that tells the client that data is still being collected. Once the function ends in the thread, how do I reload the webpage to display output.html that displays the score. This is a simpler version of what I have so far: from flask import

Dependency Injection in ASP.NET Core Worker Service

北慕城南 提交于 2020-12-31 20:06:36
问题 I'm facing some dependency injection issues in .NET Core Worker Service. Please see the below code in Program.cs file. public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsof)t", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.File(@"C:\MyApp_Log\Log.txt") .CreateLogger(); try { Log.Information("Starting up the service."); CreateHostBuilder(args).Build().Run(); return; } catch (Exception ex) { Log.Fatal(ex

Dependency Injection in ASP.NET Core Worker Service

陌路散爱 提交于 2020-12-31 20:00:17
问题 I'm facing some dependency injection issues in .NET Core Worker Service. Please see the below code in Program.cs file. public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsof)t", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.File(@"C:\MyApp_Log\Log.txt") .CreateLogger(); try { Log.Information("Starting up the service."); CreateHostBuilder(args).Build().Run(); return; } catch (Exception ex) { Log.Fatal(ex

How to make BackgroundWorker ProgressChanged events execute in sequence?

依然范特西╮ 提交于 2020-11-28 04:56:52
问题 Consider the following code: private static BackgroundWorker bg = new BackgroundWorker(); static void Main(string[] args) { bg.DoWork += bg_DoWork; bg.ProgressChanged += bg_ProgressChanged; bg.WorkerReportsProgress = true; bg.RunWorkerAsync(); Thread.Sleep(10000); } static void bg_ProgressChanged(object sender, ProgressChangedEventArgs e) { Console.WriteLine(e.ProgressPercentage); Thread.Sleep(100); Console.WriteLine(e.ProgressPercentage); } static void bg_DoWork(object sender,

How to make BackgroundWorker ProgressChanged events execute in sequence?

牧云@^-^@ 提交于 2020-11-28 04:51:24
问题 Consider the following code: private static BackgroundWorker bg = new BackgroundWorker(); static void Main(string[] args) { bg.DoWork += bg_DoWork; bg.ProgressChanged += bg_ProgressChanged; bg.WorkerReportsProgress = true; bg.RunWorkerAsync(); Thread.Sleep(10000); } static void bg_ProgressChanged(object sender, ProgressChangedEventArgs e) { Console.WriteLine(e.ProgressPercentage); Thread.Sleep(100); Console.WriteLine(e.ProgressPercentage); } static void bg_DoWork(object sender,