473,398 Members | 2,212 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,398 software developers and data experts.

VB.NET and Threading

Ill be the first to admit this is way beyond my current scope as a VB
programmer but Im learning as I go.

I playing with the new Threading features exposed by the 2.0 framework and
have writting a very simple application that executes three sequential
tasks, the second of which I send off on its on thread and it take a very
long time, so the order of completion should be Task1, Task3, Task2.

This all works, as astounding as I found that, and I am moving on to more
complex tasks with Threading, which leads me to:

When I send my second task on its on thread I use the following code:
myPingThread = New System.Threading.Thread(AddressOf myPingSub)
myPingThread.Start()

The problem here is that I cannot seem to pass an arguement to the myPingSub
as "addressof operand must be the name of a method without parentheses".

Can any of you more advanced VB guys assist me here in what Im overlooking?
How, when setting a function off on its on thread, can I pass it a value?

Thanks,
chrisj
Dec 23 '05 #1
4 3182
Make myPingSub be a member function in a class, and given the class
data members. For instance:

Module TestModule
class MyPingClass
Public data As String

Public Sub myPingSub()
System.Console.Writeline("You passed: " & data
End Sub

End Class

Public Sub Main
Dim mpc As New MyPingClass()

mpc.data = "My data"

Dim myPingThread As System.Threading.Thread = New
System.Threading.Thread(AddressOf mpc.myPingSub)
myPingThread.Start()
myPingThread.Join()

End Sub
End Module

Dec 23 '05 #2
Chris,

You know that using threading does as well mean that you use more processing
time.

I can only give you a benefit in the throughput time, however therefore you
need parallel not depended processes.

I thought you did not know that when I saw your message.

Cor
Dec 23 '05 #3
For a brief process like I am currently executing I think your right, in
that there isn't much gain in multithreading a simple ping application.

But, I'm only using that as a learning block to figure out how to thread
applications.

My main goal is to modify a current personal project I have going that is a
web image scraper using the new 2.0 classes that allow quick download of an
image
given its URL (I forget the class name). The problem I ran into was that
whenever an image was being downloaded via my loop, the GUI became
unresponsive because they are both on the same system thread, so I need a
way to send the image download off to another thread.

Hopefully by starting small like I am I can get the requisite knowledge
about threading to then use in the aforementioned project and others in the
future.

Given the additional information above, if you have suggestions about
possible alternatives, feel free to let me know!
chrisj
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2*****************@TK2MSFTNGP10.phx.gbl...
Chris,

You know that using threading does as well mean that you use more
processing time.

I can only give you a benefit in the throughput time, however therefore
you need parallel not depended processes.

I thought you did not know that when I saw your message.

Cor

Dec 23 '05 #4
Chris,

You are probably number 10001 who is doing this.

Have a look at the queue class to do this. As well know that HTTP has a
limitied ammount of connections by default. (You can tweak this) (that
scrapping you could do as well very quick in 1.x with
webclient.downloadfile).

However have a look at that queu class that makes live in this a lot easier.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor

Dec 23 '05 #5

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
11
by: Paul Sijben | last post by:
I am stumped by the following problem. I have a large multi-threaded server accepting communications on one UDP port (chosen for its supposed speed). I have been profiling the code and found...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.