Hi,
I used thread to start a process which needs one or more arguments, my
question is who to call the function from a thead? My codes are following:
Private Sub myProcess(ByVal max as integer)
Dim i As Integer
For i = 0 To max
Threading.Thread.Sleep(100)
Next
End Sub
Dim tdProcess As Threading.Thread = New Threading.Thread(AddressOf myProcess)
tdProcess.Start() 7 1154
Li Pang,
As I do it is
Create a class for your extra thread
And than
\\\the most is typed in this message so watch typos
Dim MyExtraThread as New clsExtraThread(threadInfo)
dim ExThread as New System.Threading.Thread(AddressOf
MyExtraThread.TheMethod)
ExThread.Start()
///
I hope this helps?
Cor
"Li Pang" <Li****@discussions.microsoft.com> Hi,
I used thread to start a process which needs one or more arguments, my question is who to call the function from a thead? My codes are following:
Private Sub myProcess(ByVal max as integer) Dim i As Integer For i = 0 To max Threading.Thread.Sleep(100) Next End Sub
Dim tdProcess As Threading.Thread = New Threading.Thread(AddressOf myProcess) tdProcess.Start()
Cor,
I understood that you suggested to pass the arguments through a class
initialization. It worked well. But I'd like to pass the arguments through
the Sub/Function itself. Is that possible?
Thanks for your effort.
"Cor Ligthert" wrote: Li Pang,
As I do it is
Create a class for your extra thread
And than
\\\the most is typed in this message so watch typos Dim MyExtraThread as New clsExtraThread(threadInfo) dim ExThread as New System.Threading.Thread(AddressOf MyExtraThread.TheMethod) ExThread.Start() ///
I hope this helps?
Cor
"Li Pang" <Li****@discussions.microsoft.com>
Hi,
I used thread to start a process which needs one or more arguments, my question is who to call the function from a thead? My codes are following:
Private Sub myProcess(ByVal max as integer) Dim i As Integer For i = 0 To max Threading.Thread.Sleep(100) Next End Sub
Dim tdProcess As Threading.Thread = New Threading.Thread(AddressOf myProcess) tdProcess.Start()
Li,
I don't know I do it this way, however you can as well set a global
variable.
I hope this helps?
Cor
"Li Pang" <Li****@discussions.microsoft.com> I understood that you suggested to pass the arguments through a class initialization. It worked well. But I'd like to pass the arguments through the Sub/Function itself. Is that possible?
Thanks for your effort.
"Cor Ligthert" wrote:
Li Pang,
As I do it is
Create a class for your extra thread
And than
\\\the most is typed in this message so watch typos Dim MyExtraThread as New clsExtraThread(threadInfo) dim ExThread as New System.Threading.Thread(AddressOf MyExtraThread.TheMethod) ExThread.Start() ///
I hope this helps?
Cor
"Li Pang" <Li****@discussions.microsoft.com>
> Hi, > > I used thread to start a process which needs one or more arguments, my > question is who to call the function from a thead? My codes are > following: > > Private Sub myProcess(ByVal max as integer) > Dim i As Integer > For i = 0 To max > Threading.Thread.Sleep(100) > Next > End Sub > > Dim tdProcess As Threading.Thread = New Threading.Thread(AddressOf > myProcess) > tdProcess.Start() > >
Use Delegate.BeginInvoke method:
Public Delegate Sub myDelegateABC(ByVal strA As String, ByVal intB As
Integer)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myDelegate As New myDelegateABC(AddressOf ABC)
myDelegate.BeginInvoke("ABC-StrA", 100, Nothing, Nothing)
End Sub
Private Sub ABC(ByVal strA As String, ByVal intB As Integer)
MsgBox(strA + intB.ToString)
End Sub
Cor Ligthert/Rulin Hong,
Thanks all of you.
Combining your suggestions give the best solution. The below article gives
me exactly what I need. http://www.devx.com/dotnet/Article/11358/1954?pf=true
"Li Pang" wrote: Hi,
I used thread to start a process which needs one or more arguments, my question is who to call the function from a thead? My codes are following:
Private Sub myProcess(ByVal max as integer) Dim i As Integer For i = 0 To max Threading.Thread.Sleep(100) Next End Sub
Dim tdProcess As Threading.Thread = New Threading.Thread(AddressOf myProcess) tdProcess.Start()
Li,
Can you point me in this message where is the answer on your question. I understood that you suggested to pass the arguments through a class initialization. It worked well. But I'd like to pass the arguments through the Sub/Function itself. Is that possible?
I do not see it, for the rest it is a long article, however the solution for
your first question
I used thread to start a process which needs one or more arguments, my question is who to call the function from a thead?
Is as far as I can see the same as I gave you (without the global variable
setting on your first question).
For passing back you have never asked.
Cor
"Li Pang" <Li****@discussions.microsoft.com>
Cor Ligthert/Rulin Hong,
Thanks all of you.
Combining your suggestions give the best solution. The below article gives me exactly what I need. http://www.devx.com/dotnet/Article/11358/1954?pf=true "Li Pang" wrote:
Hi,
I used thread to start a process which needs one or more arguments, my question is who to call the function from a thead? My codes are following:
Private Sub myProcess(ByVal max as integer) Dim i As Integer For i = 0 To max Threading.Thread.Sleep(100) Next End Sub
Dim tdProcess As Threading.Thread = New Threading.Thread(AddressOf myProcess) tdProcess.Start()
"Li Pang" <Li****@discussions.microsoft.com> schrieb: I used thread to start a process which needs one or more arguments, my question is who to call the function from a thead?
<URL:http://www.google.de/groups?selm=OrEuR7f7CHA.2072%40TK2MSFTNGP10.phx.gb l>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter Åstrand |
last post by:
There's a new PEP available:
PEP 324: popen5 - New POSIX process module
A copy is included below. Comments are appreciated.
----
PEP: 324
Title: popen5 - New POSIX process module
|
by: AlexeiOst |
last post by:
Everywhere in documentation there are recommendations to use threads from
thread pooling for relatively short tasks. As I understand, fetching a page
or multiple pages (sometimes up to 50 but not...
|
by: mike |
last post by:
Hi,
I am having difficulty in creating a thread using pthread_create. It
seems that pthread_create does not execute 'program', and returns -1;
I have checked the API but I am not sure why this...
|
by: Bernie Yaeger |
last post by:
I have a thread call as follows:
Dim th As New paydue
Dim bgthread As Thread = New Thread(AddressOf th.threadroutine)
bgthread.Start()
paydue is the class of the form. threadroutine looks...
|
by: Antonio Policelli |
last post by:
Cheers!
I have a sub like this
sub runProgram(programName as striing, programPath as string)
....
End sub
the sub will run another exe from within my applicaiton. I don't need
to return...
|
by: mwazir |
last post by:
Hi all,
I have a process thats starts in my application and only terminates when my
application is terminated. I want to write the output and the errors of this
process to a seperate log file....
|
by: Raith |
last post by:
Ok I'm still very new to C# and I've been searching around and getting
myself all confused so gave up and am posting here.
Vastly simplified but I have a form with some tick boxes on it,...
|
by: ryan1234 |
last post by:
My ultimate goal is to get something like "ping.exe" to re-direct it's
standardOutput in real time to an .aspx page.
I've been able to get this behavior to work just fine in a regular
console...
|
by: =?GB2312?B?0rvK18qr?= |
last post by:
Hi all,
Recently I had a new coworker. There is some dispute between us.
The last company he worked for has a special networking programming
model. They split the business logic into...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |