backgroundworker

WPF/BackgroundWorker and BitmapSource problem

北城以北 提交于 2019-12-06 03:10:49
问题 I am a beginner with WPF and trying a home project to become familiar with the technology. I have a simple form where the user selects an image file, I then display EXIF data along with a thumbnail of the image. This is working fine but when I select a RAW image file (~9 MB) there can be a slight delay while the thumb loads, so I thought I could use the BackgroundWorker to decode the image and the user can view the EXIF data, then when the image has been decoded it is displayed. The

Slow to set DataGridView DataSource to DataTable in C#

梦想与她 提交于 2019-12-06 02:52:09
I have a DataTable, fully populated, which I want to set to a DatagridView: gdv.DataSource = dt; However, this is painfully slow. The filling of the DataTable is very quick, but just this one line above takes ages. Is there any way to speed this up or perform it in another thread? There is no interaction after this point. Just the simple statement above! Thanks. Check the formatting options, especially the Fill -related properties. Adjusting columnwidths for all rows involves a lot of calculation. Here is a fix. The problem is that the framework re-resizes the columns once per row in the new

How to run a background thread in ruby?

南楼画角 提交于 2019-12-06 02:38:22
问题 I am new to ruby and thought it would be a great idea to rebuild a simple chat program I made in C#. I am using Ruby 2.0.0 MRI (Matz’s Ruby Implementation). The problem is I want to have I/O for simple server commands while the server is running. This is the server that was taken from the sample. I added the commands method that uses gets() to get input. I want this method to run as a thread in the background, but the thread is blocking the other thread. require 'socket' # Get sockets from

WPF Dispatcher Invoke return value is always null

自作多情 提交于 2019-12-06 01:27:10
问题 I have a call to a method that returns a UIElement that I call using the Dispatcher , below is the code. However the return value of the Dispatcher invoke is always NULL, any ideas? void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var slides = (IList<UIElement>)e.Argument; var bmpSlides = new List<UIElement>(); var imageService = new ImageService(); int count = 0; foreach (UIElement slide in slides) { object retVal = slide.Dispatcher.Invoke( new ThreadStart(() => imageService

Background Worker ReportProgress not firing

偶尔善良 提交于 2019-12-06 00:32:41
问题 I'm setting up a background worker for the first time. It is mostly working as the code runs and my stop/cancel button is working. However, I am also trying to report progress to update a progress bar but I cannot get this to fire at all. I start the code from a button click which runs this code: backgroundWorker1.WorkerSupportsCancellation = true; backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.RunWorkerAsync();//this invokes the DoWork event My Do_Work method: private void

C# BackgroundWorker and Com Port Problems

£可爱£侵袭症+ 提交于 2019-12-06 00:02:50
Ok. I have a program that monitors 2 COM ports. One is hooked to a scale and the other is hooked to a modbus board. My problem is in the COM port attached to the modbus board. My program is reading a sensor (on the modbus board) every 100MS. It returns a 0 or 1 (over the COM port) to determine whether the sensor is blocked. If it is blocked, a signal is sent over the port to the board. My problem is I can't quit monitoring the sensor, but I have to be sure the com port is not in use before sending my other signal. The routine that monitors the sensor is on a backgroundworker thread. Once the

Run RIA service on non UI thread

半世苍凉 提交于 2019-12-05 19:16:09
I am trying to make RIA service calls from non UI thread. I made calls with opening new thread and with background workers, but for both cases callback is running on UI thread. Is it possible to execute callback on callers thread, not UI? Thanks Ed Chapel tl;dr Use WCF Marshal your results to the UI thread yourself WCF RIA is built to do work on the UI thread WCF RIA was designed to work mostly on the UI thread. That obviously has many pros and cons; mostly cons in your case. I'm having trouble finding definitive documentation of this design, however, most questions on the topic are answered

How do I properly cancel and restart a BackgroundWorker process?

岁酱吖の 提交于 2019-12-05 18:39:39
问题 Users of my application type HTML into a TextBox control. I want my application to validate their input in the background. Because I don't want to hammer the validation service, I've tried to build in a one-second delay before each validation. However, I don't seem to be able to correctly interrupt an already-running BackgroundWorker process. My Visual Basic code: Sub W3CValidate(ByVal WholeDocumentText As String) 'stop any already-running validation If ValidationWorker.IsBusy Then

Marquee ProgressBar unresponsive with BackgroundWorker

非 Y 不嫁゛ 提交于 2019-12-05 17:47:42
In my code, when a button is clicked the progress bar is set to marquee and then my BackgroundWorker is called but when the BackgroundWorker is called the progress bar freezes or disappears. I use the BackgroundWorker to seperate the RefreshReport method of the ReportViewer from the UI thread. Any help is appreciated. Thanks! Private Sub btnOtherReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOtherReport.Click rvReport.ProcessingMode = ProcessingMode.Remote rvReport.ShowParameterPrompts = False rvReport.ServerReport.ReportServerUrl = New Uri("REPORT_SERVER

BackgroundWorker exception handling

Deadly 提交于 2019-12-05 16:56:20
问题 I'm working with the following components: a Library (which throws an exception) a test-console to test my logging the enterprise library exception handling application blocks the enterprise library logging application blocks I'm invoking the library method by using a backgroundworker. The library throws the exception but the RunWorkerCompleted handler is never called. The only way to catch the exception is to surround my DoWork handler code with a try/catch block. Did is misunderstand the