473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Thread starting problem

hello,

I encounter a problem using threads. I have a simple code to use a thread :

cSurveillanceBorne = New clsThreadSurveillance
_SurveillanceThread = New Thread(AddressOf cSurveillanceBorne.SurveilleBorne)
_SurveillanceThread.Start()

This code work perfectly on my workstation. I use Visual Studio 2003, and
the CLR version is 1.1.4322.573

But when, i copy this assembly on another workstation that have only the
redistribuable CLR, the thread doesn't start !!! The only difference i have
noted is :
- CLR version is 1.1.4322.2032 on the other workstation
- Visual Studio is not installed

I'm a bit disappointed, and have tried some different way to lauch my
thread, but without success. I will be great if someone coul help...

kind regards,
--
Thanks,

Cedric
Nov 22 '05 #1
6 1999
what does your thread do? does it rely on external resources. i'm pretty
sure the thread starts, it probably dies with an exception. put another way,
i've never seen a thread not start when it wasn't due to program logic error

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
"cedric" <ch****@online.nospam> wrote in message
news:A7**********************************@microsof t.com...
hello,

I encounter a problem using threads. I have a simple code to use a thread
:

cSurveillanceBorne = New clsThreadSurveillance
_SurveillanceThread = New Thread(AddressOf
cSurveillanceBorne.SurveilleBorne)
_SurveillanceThread.Start()

This code work perfectly on my workstation. I use Visual Studio 2003, and
the CLR version is 1.1.4322.573

But when, i copy this assembly on another workstation that have only the
redistribuable CLR, the thread doesn't start !!! The only difference i
have
noted is :
- CLR version is 1.1.4322.2032 on the other workstation
- Visual Studio is not installed

I'm a bit disappointed, and have tried some different way to lauch my
thread, but without success. I will be great if someone coul help...

kind regards,
--
Thanks,

Cedric

Nov 22 '05 #2
Hello Alvin,

Thanks for your help. The thread is a loop, it just ping an IP address at a
fixed interval. I have put a messagebox as first instruction of the thread ,
and it doesn't display. I've tried a Try..Catch block for the
_SurveillanceThread.Start(), but there is'nt error !

I will try to delete all the code of the thread, just let the messagebox,
and will post back the results.
"Alvin Bruney [ASP.NET MVP]" wrote:
what does your thread do? does it rely on external resources. i'm pretty
sure the thread starts, it probably dies with an exception. put another way,
i've never seen a thread not start when it wasn't due to program logic error

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
"cedric" <ch****@online.nospam> wrote in message
news:A7**********************************@microsof t.com...
hello,

I encounter a problem using threads. I have a simple code to use a thread
:

cSurveillanceBorne = New clsThreadSurveillance
_SurveillanceThread = New Thread(AddressOf
cSurveillanceBorne.SurveilleBorne)
_SurveillanceThread.Start()

This code work perfectly on my workstation. I use Visual Studio 2003, and
the CLR version is 1.1.4322.573

But when, i copy this assembly on another workstation that have only the
redistribuable CLR, the thread doesn't start !!! The only difference i
have
noted is :
- CLR version is 1.1.4322.2032 on the other workstation
- Visual Studio is not installed

I'm a bit disappointed, and have tried some different way to lauch my
thread, but without success. I will be great if someone coul help...

kind regards,
--
Thanks,

Cedric


Nov 22 '05 #3
Hello Again,

I found why the thread wasn't starting. In fact, you put me on the way
alvin. With a simple messagebox the thread was starting. What is very
confusing, is that when an error produce in a thread, the thread doesn't fire
any error, so it's very difficult to debug.

I have put the faulty code in a simple method, and what was my surprise when
an error displayed me that it can't found Microsoft.VB6 compatibility library
! My thread was using VB6.GetPath, and it work perfectly on my workstation,
but just doesn't work on the other because the version of this library is not
the same.

So i'm a bit disappointed, i thought that DLL hell was finished with the
framework DotNet, but not ! Should i have to include all the framework DLL
that i import in my project when i install it on another PC, or there is an
easier way by configuring a config file ?

Thanks,

Cedric

"cedric" wrote:
Hello Alvin,

Thanks for your help. The thread is a loop, it just ping an IP address at a
fixed interval. I have put a messagebox as first instruction of the thread ,
and it doesn't display. I've tried a Try..Catch block for the
_SurveillanceThread.Start(), but there is'nt error !

I will try to delete all the code of the thread, just let the messagebox,
and will post back the results.
"Alvin Bruney [ASP.NET MVP]" wrote:
what does your thread do? does it rely on external resources. i'm pretty
sure the thread starts, it probably dies with an exception. put another way,
i've never seen a thread not start when it wasn't due to program logic error

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
"cedric" <ch****@online.nospam> wrote in message
news:A7**********************************@microsof t.com...
hello,

I encounter a problem using threads. I have a simple code to use a thread
:

cSurveillanceBorne = New clsThreadSurveillance
_SurveillanceThread = New Thread(AddressOf
cSurveillanceBorne.SurveilleBorne)
_SurveillanceThread.Start()

This code work perfectly on my workstation. I use Visual Studio 2003, and
the CLR version is 1.1.4322.573

But when, i copy this assembly on another workstation that have only the
redistribuable CLR, the thread doesn't start !!! The only difference i
have
noted is :
- CLR version is 1.1.4322.2032 on the other workstation
- Visual Studio is not installed

I'm a bit disappointed, and have tried some different way to lauch my
thread, but without success. I will be great if someone coul help...

kind regards,
--
Thanks,

Cedric



Nov 22 '05 #4
Hi Cedric,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that one of your thread is terminated with
an exception. If there is any misunderstanding, please feel free to let me
know.

As Alvin mentioned, when an exception is thrown by the sub thread, the main
thread will not be aware of it and the sub thread is terminated. We can
only get known of it in the appdomain. Try to add the following code:

static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
Application.Run(new Form1());
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
MessageBox.Show("Exception thrown");
}

I see that you are using the VB6 code in you VB.NET project. It might be
the cause of the exception, because these methods doesn't exist in .NET
framework and need to interop with unmanaged DLLs. So you might need to
redistribute these DLLs with your app.

Could you let me know what you're trying to do with the VB6 code, so that I
can find an equivalent way using .NET class library to achieve that. Could
you please provide me with the thread code? Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 22 '05 #5
Hello Kevin,

Thanks for your help. Sorry for the multi-posting, the first time, my
browser return me that there were a problem with my request, so i clicked
twice... You're right, my thread was terminated with an exception. Thanks for
your snippet, i will add this to my code in order to handle sub Thread errors
now.

I was using "VB6.GetPath" from Microsoft.VisualBasic.Compatibility.dll, in
order to get the path where the app is installed. I have replaced it by
"Application.StartupPath". I'm not sure it's the same (because startup path
may not be the same as the application path), but it seems to work.

The problem was, that Microsoft.VisualBasic.Compatibility.dll is present in
the CLR of my workstation, but not on the other one. So without the DLL, no
way to work :) What i don't understand is why this dll is not present in the
other framework. I use Visual Studio, and maybe it adds some dll, that the
redistribuable framework don't include...

Thanks,

Cedric

"Kevin Yu [MSFT]" wrote:
Hi Cedric,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that one of your thread is terminated with
an exception. If there is any misunderstanding, please feel free to let me
know.

As Alvin mentioned, when an exception is thrown by the sub thread, the main
thread will not be aware of it and the sub thread is terminated. We can
only get known of it in the appdomain. Try to add the following code:

static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
Application.Run(new Form1());
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
MessageBox.Show("Exception thrown");
}

I see that you are using the VB6 code in you VB.NET project. It might be
the cause of the exception, because these methods doesn't exist in .NET
framework and need to interop with unmanaged DLLs. So you might need to
redistribute these DLLs with your app.

Could you let me know what you're trying to do with the VB6 code, so that I
can find an equivalent way using .NET class library to achieve that. Could
you please provide me with the thread code? Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 22 '05 #6
Hi Cedric,

Yes, you can use Application.StartupPath for an equivalence. As I
know,Microsoft.VisualBasic.Compatibility.dll is installed with Visual
Studio .NET. It is used by VB6 upgrade wizard, and is not a part of .NET
framework. So it's better to use a .NET framework method to achieve this.
HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 22 '05 #7

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

Similar topics

2
by: Bruce Bon | last post by:
The class below is intended to play a Sun audio file (.au) in the background while the main thread, which is servicing a GUI, continues without impact. It doesn't work. For a sound file that...
9
by: phil | last post by:
And sorry I got ticked, frustrating week >And I could help more, being fairly experienced with >threading issues and race conditions and such, but >as I tried to indicate in the first place,...
44
by: Charles Law | last post by:
Hi guys. I'm back on the threading gig again. It's the age-old question about waiting for something to happen without wasting time doing it. Take two threads: the main thread and a worker...
4
by: cedric | last post by:
hello, I encounter a problem using threads. I have a simple code to use a thread : cSurveillanceBorne = New clsThreadSurveillance _SurveillanceThread = New Thread(AddressOf...
6
by: Tony Proctor | last post by:
Hi everyone We're experiencing some serious anomalies with the scheduling of ASP threads. I'd be interested to hear if anyone knows what algorithm is used (e.g. simple round-robin, or something...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
8
by: JS | last post by:
I am monitoring/controlling some realtime activities in a manufacturing process. When a part comes into my station, I have a bunch of processing to do. There are 30-40 data acquisition and data...
3
by: NaeiKinDus | last post by:
Hello, i'm trying to program a thread that would be locked (by a mutex) and that would only be unlocked once that a function (generating data) is done. The purpose is to generate data, and unlock...
15
by: suga.masanobu | last post by:
Hello group. I have thread in which I perform specific task in loop. I can specify, by check box, in what periods of time that task should be done, ex. instantly, with 5min break, with 15min...
16
by: Hendrik van Rooyen | last post by:
I thought I would share this nasty little gotcha with the group. Consider the following code fragment: <start> print 'starting kbd thread' keyboard_thread = thread.start_new_thread(kbd_driver...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.