473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thread.Start in sub main

Using VS 2003, VB.net , MSDE ....

I am confused by the help example below. In a sub main (whether in a module
or winform), do you have to explicitly start the Main_Thread, as they do in
this example? If the answer is not always, when and where would you and for
what reasons? I don't explicitly start the thread (although I give it a
name) in a module Sub Main, and it still lists the thread as being created
in the threads window.

Thanks!
Bob

Setting a Thread Name (Managed)

Public Class Form1 : Inherits Form
Class Needle
' This method will be called when the thread is started
Sub Baz()
Console.WriteLine("Needle Baz is running on another thread")
End Sub
End Class

Public Shared Sub Main()
Console.WriteLine("Thread Simple Sample")
Dim oNeedle As New Needle()
' Create a Thread object
Dim oThread As New Thread(AddressOf oNeedle.Baz)
' Set the Thread name to "MainThread"
oThread.Name = "MainThread"
' Starting the thread invokes the ThreadStart delegate
oThread.Start()
End Sub
End Class
Nov 20 '05 #1
4 1518
"Bob Day" <Bo****@TouchTalk.net> schrieb
Using VS 2003, VB.net , MSDE ....

I am confused by the help example below. In a sub main (whether in a
module or winform), do you have to explicitly start the Main_Thread,
as they do in this example?
No. It's an example how to start a thread and set it's name.
If the answer is not always, when and
where would you and for what reasons? I don't explicitly start the
thread (although I give it a name) in a module Sub Main, and it
still lists the thread as being created in the threads window.


If you don't need another thread, you don't have to create one.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Hi Bob,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you are confusing about the
example in MSDN help.(Setting a Thread Name (Managed))

I agree with Armin's suggestion that when the application start, the
program will run from the Sub Main(). in the third line in the Sub Main(),
the program will create a new thread, in the Line oThread.Start(), the
new created thread will start to run, it will run the Thread Procedure
Baz(), so the "MainThread" is the name of the new created thread, you can
specify its name to other string. The example is to demostrate how to set
the name of a new thread.

Usually, if you do not need to do multiple thread working, you do not need
to create the new thread. When the application starts to run, it will run
from a specified method(entry point, Startup Object), in this case, the
method is the Public Shared Sub Main() method.

A process can create one or more threads to execute a portion of the
program code associated with the process. The thread to run the Public
Shared Sub Main() will be created automatically, you do not need to create
it.

StartupObject Property
http://msdn.microsoft.com/library/de...us/vbcon/html/
vxlrfvslangprojprojectpropertiesstartupobject.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3
Hi Bob,

Thanks for posting in the community.

Did my reply answer your question?

If you have any concern on this issue,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
The issues is resolved, thanks.

Bob Day

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:51**************@cpmsftngxa07.phx.gbl...
Hi Bob,

Thanks for posting in the community.

Did my reply answer your question?

If you have any concern on this issue,please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

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

Similar topics

2
2395
by: Olivier Parisy | last post by:
Hi, I like to use thread to simplify the handling of independant, blocking tasks. But controling them from a main thread is not always easy to do in a clean way. So I've written some generic...
0
2048
by: Marco Nicosia | last post by:
Hello gang, My coworker and I are writing a Python class for the other developers within our team. This class is supposed to encapsulate several things, including daemonizing, setting up...
0
1223
by: Ivan | last post by:
Hi there My work on threads continues with more or less success. Here is what I'm trying to do: Class JobAgent is incharged for some tasks and when it's called it starts thread which performs...
7
439
by: Ivan | last post by:
Hi there My work on threads continues with more or less success. Here is what I'm trying to do: Class JobAgent is incharged for some tasks and when it's called it starts thread which performs...
6
2270
by: Daniel | last post by:
i have an array that i want all threads to be able to READ from concurrently, however, at times i want to UPDATE the array. at which point i want all threads that use it to block when they try to...
7
2671
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
3
1868
by: JohnnyGr | last post by:
I have heard theres a new way to start threads with parameters in framework 2.0, does anyone know how to do that? this is what i need to do... Start a thread that executes some stuff, in this...
12
31860
by: Andrew Bullock | last post by:
Hi, I'm using a second thread within my program to do some long calculations, without locking up the UI: worker = new Thread(new ThreadStart(myClass.Run)); worker.Start(); I want to be...
6
6226
by: Padhu Vinirs | last post by:
JDK 1.4 on WinXP. I have 2 threads started from the main thread. I would like to print some status of the child threads from the main thread periodically. But I dont see the main thread to print...
1
2507
by: raghudr | last post by:
Hi all, I am displaying a splash screen for which i have created a thread.Since my whole project is launched by windows service and that service will start automatically at the start of the...
0
7202
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,...
0
7084
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
7278
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
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
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...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...

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.