backgroundworker

Writing a polling Windows service

我是研究僧i 提交于 2019-12-12 08:38:35
问题 I usually write Windows services in C# but I'm giving it a go in F#. For a polling serivce, like this one, I ordinarily use a class I've written, which is similar to BackgroundWorker. It spawns a background thread and fires an OnWork method at regular intervals. (Complete code is here [github].) Is there another, perhaps better or more idiomatic, way to do this in F#? It could be a better way to write the polling background worker class, or built-in alternatives to it. EDIT Here's what I came

How to handle exceptions from a BackgroundWorker thread?

我与影子孤独终老i 提交于 2019-12-12 08:37:54
问题 In a WPF app I have a sheduled database access task, periodically run by a timer and this task have been executed in a BackgroundWorker thread. When connection attempt failed I raise an exception by try_catch construction and I want to update a Status Bar text in a UI thread. Is there some prebuild event construction in a BackgroundWorker for implementing this, something like DoWorkEventHandler or RunWorkerCompletedEventHandler , which can be used for this? If not, how to do it better? Edited

Best way to report thread progress

早过忘川 提交于 2019-12-12 07:38:31
问题 I have a program that uses threads to perform time-consuming processes sequentially. I want to be able to monitor the progress of each thread similar to the way that the BackgroundWorker.ReportProgress / ProgressChanged model does. I can't use ThreadPool or BackgroundWorker due to other constraints I'm under. What is the best way to allow/expose this functionality. Overload the Thread class and add a property/event? Another more-elegant solution? 回答1: Overload the Thread class and add a

How to use Task.run to perform the function of Do_Work() of a background worker

血红的双手。 提交于 2019-12-12 06:56:44
问题 I move 4 objects in parallel in a specific paths stored in a list of paths, when each of them complete one path(specific coordinates) it switches to another!. I used 4 background workers to perform such a job in background and in each call each background worker should try 6 paths (chromosomes) extracted from an a text file and each path stored in different 6 lists and each list contains the coordinates for each path. The coordinates then converted to 2D points to perform projection and each

Creating a WinForm on the main thread using a backgroundworker

≡放荡痞女 提交于 2019-12-12 06:15:33
问题 I've got a background worker and I'm trying to get it to create an instance of a form, but I don't want the background worker thread to own the object, but would like the main thread to own it. Where do I start with this? 回答1: You can use the Invoke and BeginInvoke functions to get the code to execute on the GUI thread. You could get your other thread to raise an event, then handle it in your main form, then your main form could invoke that call back onto its own thread (using InvokeRequired

Highly Responsive Multi Threaded WPF Application

你说的曾经没有我的故事 提交于 2019-12-12 06:09:10
问题 I Am Working on WPF Application to communicate with 16 Devices through Serial Port. Communication Process includes read and write Commands. Configuration of device takes around 2 minutes. My UI should be responsive during configuration process, that it should show reading after read commands execution and show command status after write commands execution. I used backgroundworker for handling one device. Everything works fine. Now i need to run all 16 devices simultaneously. How do i do it?

Background worker issue

北战南征 提交于 2019-12-12 04:19:51
问题 i have a class which, when a certain part of the gui is clicked will -create a backgroundworker and do the following taks -create a new object(this is a new windows form) -call a method on it which gets some data -populate the new windows form gui with that data The problem is there is a gui component on the form which cant be created from outside of the main programme thread, if i do try i get the error Active x .... cannot be instantiated because the current thread is not in a single

Dispatcher.Invoke loop freeze UI

心已入冬 提交于 2019-12-12 04:07:18
问题 I have log tailing app which is executing Background worker thread in infinitive loop and checking for latest entries inside some TXT file. Once it find new entries I use Dispatcher.Invoke to update TextBox on the screen with latest entry added to the text file. The problem is that if the source text file is being updated constantly every millisecond the user interface is just freezing since Dispatcher.Invoke is updating Textbox so often. Wonder if there is any workaround. I could get bigger

Show a form while BackgroundWorker is running

血红的双手。 提交于 2019-12-12 03:14:21
问题 I want to display a "loading form" (a form with some text message plus a progressBar with style set to marquee) while the BackgroundWorker 's job isn't done. When the BackgroundWorker is done, the loading form must be closed automatically. Although I do use a BackgroundWorker , the main thread should wait until it's done. I was able to do that using a AutoResetEvent but I noticied that as it does block the main thread, the form loading's progressBar is freezed too. My question is: How can I

How to properly detect when multiple threads within another thread are fully complete?

寵の児 提交于 2019-12-12 02:46:05
问题 I'm running several BackgroundWorker threads that are being used to execute queries to retrieve DataSets all within another BackgroundWorker thread. Let's call the thread that is running these multiple threads the 'Host Thread' and the others 'Query Thread'. What I am trying to do is to tell when all of the query threads are finished populating their DataSets by utilizing the host thread's RunWorkerCompleted event. The first line in this event handler is while (dataSets.Count < count) {