473,809 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A simple thread freezes between DoWork and RunWorkerComple ted

I am running an application that, when not used, just sits there firing a
BackgroundWorke r every 20 seconds. Every now and then, the BackgroundWorke r
freezes between the DoWork and RunWorkerComple ted procedures. My simplified
procedures are shown below. They endlessly write messages to a text file.
At some point it never moves from DoWork to RunWorkerComple ted. I do have
services such as Outlook and Norton SystemWorks running in the background.
Any ideas why the BackgroundWorke r freezes between these procedures for no
apparent reason. Could it be some other background service causing the
problem? It has never ran a complete day without freezing.

Each of these procedures has error trapping that shows a message if there is
an error. I never see the message indicating that whatever is happening is
not caused by a trappable error.

Private Sub BackgroundWorke r1_DoWork(XXXX) Handles BackgroundWorke r1.DoWork
C.DoMsg(Now & " BackgroundWorke r1_DoWork -2")
C.DoMsg(Now & " BackgroundWorke r1_DoWork Finish")
End Sub

Private Sub BackgroundWorke r1_RunWorkerCom pleted(XXXX) Handles
BackgroundWorke r1.RunWorkerCom pleted
C.DoMsg(Now & " BackgroundWorke r1_RunWorkerCom pleted Start")
C.DoMsg(Now & " BackgroundWorke r1_RunWorkerCom pleted Finish")
End Sub

Friend Sub DoMsg(ByVal psMsg As String)
Debug.Print(psM sg)
Dim oSW As StreamWriter = New StreamWriter("C :\Temp\AppMsg.t xt", pbAppend)
oSW.WriteLine(p sMsg)
oSW.Close()
End Sub

My code in the timer is:

If Not BackgroundWorke r1.IsBusy Then
Me.BackgroundWo rker1.RunWorker Async()
End If

********Sample log.
6/14/2006 1:13:39 AM BackgroundWorke r1_RunWorkerCom pleted Finish
tmrAutoRecover_ Tick
6/14/2006 1:13:39 AM BackgroundWorke r1_DoWork -2
6/14/2006 1:13:39 AM BackgroundWorke r1_DoWork Finish
6/14/2006 1:13:39 AM BackgroundWorke r1_RunWorkerCom pleted Start
6/14/2006 1:13:39 AM BackgroundWorke r1_RunWorkerCom pleted Finish
tmrAutoRecover_ Tick
6/14/2006 1:13:51 AM BackgroundWorke r1_DoWork -2
6/14/2006 1:13:51 AM BackgroundWorke r1_DoWork Finish
6/14/2006 1:13:51 AM BackgroundWorke r1_RunWorkerCom pleted Start
6/14/2006 1:13:51 AM BackgroundWorke r1_RunWorkerCom pleted Finish
tmrAutoRecover_ Tick
6/14/2006 1:14:07 AM BackgroundWorke r1_DoWork -2
6/14/2006 1:14:07 AM BackgroundWorke r1_DoWork Finish
********Log stops at this point, Application is frozen.

Jun 14 '06 #1
0 2708

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4857
by: Pieter | last post by:
Hi, I'm having some weird problem using the BackGroundWorker in an Outlook (2003) Add-In, with VB.NET 2005: I'm using the BackGroundWorker to get the info of some mailitems, and after each item I want to raise the ProgressChanged-event to update the DataGridView. It works fine when only one Progresschanged is fired, but at the second, third, fopurth etc it raises everytile a 'Cross-thread operation not valid"-exception on lmy...
3
1298
by: Ryan Pedersen | last post by:
I have a small program that executes a single very long running background thread today. The scope of all variables in the method that is running in this thread today are all local to the method. The method doesn't do anything outside of its local scope. My question... can I start up a 2nd (3rd, and 4th and so on) thread running the same method? Is that safe?
7
1685
by: Tommaso Caldarola | last post by:
How to I can know the UI thread? I need to do a switch context before to read/write some data. Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
3
3201
by: John Wright | last post by:
I have a background worker thread that scans the network listing computers that are connected. I have a delegate that I call that invokes a procdure that loads a dataset with computer names and then attaches it to a dropdown. When I run it, my UI freezes until it completes. Any thoughts on how to do this without freezing the UI? John Code
8
5375
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In this code there is a panel panel1, that I populate with a lable in the foreground. Then when I click on "button1" a backgroundworker thread in async mode is started. When the backgoundworker thread completes the thread returns a panel to populate...
9
3256
by: Pubs | last post by:
Hi all, I want to call a function with some intial parameters with in a thread. At the end of the function execution it should return a value to the caller. Caller is outside the thread. Example function test (int a, int b);
2
1302
by: vapordan | last post by:
Can someone spot the issue in this background thread implementation? The docs say, the RunWorkerCompleted must fire irrespective of exception. It does so on my machine when there is no loop. When the loop is present, with at least a time delay, the completed event never fires. Am I missing something? Imports System.Threading Public Class Form1 Dim _BackgroundWorkerFinished As Boolean = False Private WithEvents _BackgroundWorker As New
9
6996
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table population. Whenever I call the thread, I pass it a structure containing the table and a few other parameters. The table goes in as a reference, but the other items are passed normally.
2
1121
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
Using Visual Studio 2005 Professional: I have two thread routines in one project at this time. One came from me dropping a BackgroundWorker component on my form and setting the properties for it. Whenever this worker completes, I return the results back to the main form using DoWork's DoWorkerEventArgs variable, which has the Result object that I can set before the thread exits. Another worker thread in this project is constructed on...
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.