By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

New to Threading

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.