473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New to Threading

Hi All,
I have the most basic understanding of using Threading. I have no problem
creating a thread, addressing it to a Sub Procedure, and Starting the
Thread. Works Great!

My problem is the following:
I have:

1.A function that returns a Boolean
2.The Function calls different Sub Procedures on a variable numbered basis.
(meaning the procedures can be called either once or a hundred times within
the function.
3.The Function and procedures write data to the Form.

All this works great without Threading.
When using Threading, AddressOF (Function) I get problems.

1.My form's display is not updated properly, or at least the list boxes and
datagrids go blank or Visibility = False.
2.If attempting to run the function again I get an error in the Main Forms
Module "Error Creating Windows Handle" on "MyBase.Dispose(disposing)"
3. Any form object the Functions and procedures references, such as
ListView, Label, DataGrid, become invisible after the thread completes and
they do not come back even if I specifically set the visibility to True
after the thread.

Any ideas on this would be greatly appreciated.
John.
Nov 20 '05 #1
5 1577
"John Rugo" <jr***@patmedia.net> schrieb
Hi All,
I have the most basic understanding of using Threading. I have no
problem creating a thread, addressing it to a Sub Procedure, and
Starting the Thread. Works Great!

My problem is the following:
I have:

1.A function that returns a Boolean
2.The Function calls different Sub Procedures on a variable numbered
basis. (meaning the procedures can be called either once or a hundred
times within the function.
3.The Function and procedures write data to the Form.

All this works great without Threading.
When using Threading, AddressOF (Function) I get problems.

1.My form's display is not updated properly, or at least the list
boxes and datagrids go blank or Visibility = False.
2.If attempting to run the function again I get an error in the Main
Forms Module "Error Creating Windows Handle" on
"MyBase.Dispose(disposing)"
3. Any form object the Functions and
procedures references, such as ListView, Label, DataGrid, become
invisible after the thread completes and they do not come back even
if I specifically set the visibility to True after the thread.

A control must only be accessed from the thread that created the control. If
you want to access the control (a Form is a control) from a different
thread, you must call the control's Invoke or BeginInvoke method.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Thanks, but could you please give me an example of how this works? I was
able to access the control on a form when threading a single Sub Procedure
in the form that accessed the form's controls.

The function is much more complex it seems.

Thanks,
John.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"John Rugo" <jr***@patmedia.net> schrieb
Hi All,
I have the most basic understanding of using Threading. I have no
problem creating a thread, addressing it to a Sub Procedure, and
Starting the Thread. Works Great!

My problem is the following:
I have:

1.A function that returns a Boolean
2.The Function calls different Sub Procedures on a variable numbered
basis. (meaning the procedures can be called either once or a hundred
times within the function.
3.The Function and procedures write data to the Form.

All this works great without Threading.
When using Threading, AddressOF (Function) I get problems.

1.My form's display is not updated properly, or at least the list
boxes and datagrids go blank or Visibility = False.
2.If attempting to run the function again I get an error in the Main
Forms Module "Error Creating Windows Handle" on
"MyBase.Dispose(disposing)"
3. Any form object the Functions and
procedures references, such as ListView, Label, DataGrid, become
invisible after the thread completes and they do not come back even
if I specifically set the visibility to True after the thread.

A control must only be accessed from the thread that created the control. If
you want to access the control (a Form is a control) from a different
thread, you must call the control's Invoke or BeginInvoke method.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #3
Thanks, but could you please give me an example of how this works? I was
able to access the control on a form when threading a single Sub Procedure
in the form that accessed the form's controls.

The function is much more complex it seems.

Thanks,
John.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...
"John Rugo" <jr***@patmedia.net> schrieb
Hi All,
I have the most basic understanding of using Threading. I have no
problem creating a thread, addressing it to a Sub Procedure, and
Starting the Thread. Works Great!

My problem is the following:
I have:

1.A function that returns a Boolean
2.The Function calls different Sub Procedures on a variable numbered
basis. (meaning the procedures can be called either once or a hundred
times within the function.
3.The Function and procedures write data to the Form.

All this works great without Threading.
When using Threading, AddressOF (Function) I get problems.

1.My form's display is not updated properly, or at least the list
boxes and datagrids go blank or Visibility = False.
2.If attempting to run the function again I get an error in the Main
Forms Module "Error Creating Windows Handle" on
"MyBase.Dispose(disposing)"
3. Any form object the Functions and
procedures references, such as ListView, Label, DataGrid, become
invisible after the thread completes and they do not come back even
if I specifically set the visibility to True after the thread.

A control must only be accessed from the thread that created the control. If
you want to access the control (a Form is a control) from a different
thread, you must call the control's Invoke or BeginInvoke method.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #4
"John Rugo" <jr***@patmedia.net> schrieb
Thanks, but could you please give me an example of how this works? I
was able to access the control on a form when threading a single Sub
Procedure in the form that accessed the form's controls.

The function is much more complex it seems.

Button1.BeginInvoke(New MethodInvoker( _
AddressOf ProcedureUpdatingControl _
))

Private Sub ProcedureUpdatingControl()
Button1.Text = "progress"
End Sub
MethodInvoker is a predefined Delegate but you can define one on your own to
be able to pass arguments to the procedure.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
"John Rugo" <jr***@patmedia.net> schrieb
Thanks, but could you please give me an example of how this works? I
was able to access the control on a form when threading a single Sub
Procedure in the form that accessed the form's controls.

The function is much more complex it seems.

Button1.BeginInvoke(New MethodInvoker( _
AddressOf ProcedureUpdatingControl _
))

Private Sub ProcedureUpdatingControl()
Button1.Text = "progress"
End Sub
MethodInvoker is a predefined Delegate but you can define one on your own to
be able to pass arguments to the procedure.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

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

Similar topics

65
6659
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
2952
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
5207
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
555
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
2230
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
4984
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
6385
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
1565
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
2347
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
6599
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
7132
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
7009
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
7178
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,...
1
6899
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
7390
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...
0
5475
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
4602
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...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
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...

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.