backgroundworker

Cancelling background-worker

試著忘記壹切 提交于 2019-12-25 07:46:55
问题 I have the following problem and I hope someone will be able to help me with it. I have a worker in VB .net (2010) which runs a shell-program. The shell program is a service and output stuff like: Server initializing... Server opening port... more info... I am able to 'catch' the output of the shell and add it to a textbox (using set text function). And I am able to Cancel the worker by clicking on a stopbutton, however when there is no more output by the shell I cannot stop the worker

BackgroundWorker.RunWorkerCompleted event in WPF

坚强是说给别人听的谎言 提交于 2019-12-25 03:08:57
问题 There is a scenario in which a user terminates the application, while it is still processing data via BackgroundWorker. I would like to send cancel or terminate command to this method. I tried calling CancelAsync() method, but it obviously didn't work the way I expected and the worker still continued processing. What is a good way to signal the BackgroundWorker, and especially its RunWorkerCompleted method to stop processing? Do I have to use state variables? 回答1: This is the code executed

BackgroundWorker 'DoWork' event not firing

雨燕双飞 提交于 2019-12-25 03:08:36
问题 I have a form that loads just fine, and I'm trying to fire off a task using a Background Worker as it loads. I'm getting no errors with the code below, but the bw.DoWork event doesn't seem to be firing. Am I missing something here? Thanks. Here is my form Class - Public Class mainForm Dim objWorker As MyWorker Private Sub mainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call Me.loadForm() End Sub Private Sub btnCancel_Click(ByVal sender As System

WPF mvvm backgroundworker UI displaying different results

只谈情不闲聊 提交于 2019-12-25 02:47:21
问题 So finally i managed to create a working BackgroundWorker. I used the ReportProgress method to updated UI elements in this way: bw.ReportProgress(1, node); bw.ReportProgress(2, connection); bw.ReportProgress(3); bw.ReportProgress(4, system); Where the connection is a model Object, this is my progress method: void bw_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage == 1) //update nodes { this.Network.Nodes.Add((NodeViewModel)e.UserState); } if (e

Background worker hangs whole application

岁酱吖の 提交于 2019-12-25 02:12:26
问题 Ok here's the pretty light code: // // numConfigsBindingSource // this.numConfigsBindingSource.DataMember = "NumConfigs"; this.numConfigsBindingSource.DataSource = this.DSNumConfigs; // Grid this.GridNumConfigs.DataSource = this.numConfigsBindingSource; // // DSNumConfigs // this.DSNumConfigs.DataSetName = "DSNumConfigs"; this.DSNumConfigs.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // numConfigsTableAdapter // this.numConfigsTableAdapter.ClearBeforeFill =

C# BackgroundWorker Not Working

大兔子大兔子 提交于 2019-12-24 21:19:52
问题 I'm trying to get this BackgroundWorker to work. When you click the View Orders button, it will display a message along the lines of "Retrieving new orders..." etc, and will do background work (mysql query), now, there's a bunch of stuff inside the DoWork method, and none of it gets done. I know it's not because of the MySQL Query because it works fine on its own without the background worker. Here's the code: private void ViewOrders_Click(object sender, EventArgs e) { SlideTimer.Enabled =

Using Await in BackgroundWorker causes WorkerComplete event to be raised

有些话、适合烂在心里 提交于 2019-12-24 21:16:33
问题 I have this weird problem. I need to invoke a process from within a background worker Private Shared _process As Process Private Shared _StartInfo As ProcessStartInfo Private WithEvents _bwConvertMedia As New BackgroundWorker Here is the work in DoWorkAsync Private Async Sub _bwConvertMedia_DoWorkAsync(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles _bwConvertMedia.DoWork For AI = 1 To 100 _StartInfo = New ProcessStartInfo(".\mycmd.exe", "-1") _StartInfo

Main UI windows not updating control -Cross-thread operation not valid

巧了我就是萌 提交于 2019-12-24 17:29:46
问题 Ok..here is the problem I have a main UI form that has a control container that i can add some buttons item to it,and also i have a backgroundworker object that starts up a listner. When the listner events fire, i would like to create a button in that control container on the main UI form. Everything seems to work fine until i try to add a new control item to that container. I get the following exception "Cross-thread operation not valid: Control 'RadMagnifier_AcceptReject' accessed from a

Instantiating an object in a background worker causes the UI to freeze up

我的梦境 提交于 2019-12-24 14:35:59
问题 This is what i have at the moment, but when i call Dispatcher.BeginInvoke() , my UI freezes up: BackgroundWorker backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.WorkerReportsProgress = true; ViewModel.GenerateReport(backgroundWorker, Dispatcher); ViewModel: backgroundWorker.DoWork += delegate(object s, DoWorkEventArgs args) { try { ReportViewModel reportViewModel = new ReportViewModel(SessionContext, Mediator,

Form does not displayed as Dialog inside backgroundworker?

人走茶凉 提交于 2019-12-24 14:31:54
问题 the Form does not displayed as Dialog inside backgroundworker? Here is my code: //From Form1 private void backgroundWorkerResult_DoWork(object sender, DoWorkEventArgs e) { //do something here backgroundWorkerResult.ReportProgress(100); frmMessageBox frmMsgBox = new frmMessageBox(); frmMsgBox.ShowDialog(); } Even though i already showed the frmMsgBox as a dialog i Can still click the Form1 that supposed to be not? how can fix this? 回答1: I created a simple code sample that you can use to