473,465 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need to add control from one thread into the control collection of a form in another thread...

....is this possible?
Jun 27 '08 #1
7 1541
"Jameson" <mr********@gmail.comschrieb
...is this possible?
You'd better put the question in the body not in the subject line.

Answer: Yes. Call the form's invoke/begininvoke method. In the procedure
called by invoke/begininvoke, add the control.
Armin






Jun 27 '08 #2
Jameson,

I am always curious from people what they are doing, this newsgroup is to
learn for everybody you know.

A control is a kind of UI.

How do your users enter data Assynchonously in those controls?

Cor

"Jameson" <mr********@gmail.comschreef in bericht
news:90**********************************@microsof t.com...
...is this possible?

Jun 27 '08 #3
Lets say my form1 needs to perform some operation and I designed a custom
control that will show the user some information about the operation. Well
For the sake of seamlessness I would rather have that control added to the
control list of form1 and have it run on its own thread so that the user can
see the updates happening, and the operations going on in form1 will not be
effected.

My form1 is docked to the top of the users screen, so I do not have to worry
about the user being able to move it or interact with it in any way while
the operation is underway.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:um**************@TK2MSFTNGP02.phx.gbl...
Jameson,

I am always curious from people what they are doing, this newsgroup is to
learn for everybody you know.

A control is a kind of UI.

How do your users enter data Assynchonously in those controls?

Cor

"Jameson" <mr********@gmail.comschreef in bericht
news:90**********************************@microsof t.com...
>...is this possible?

Jun 27 '08 #4
Small example maybe?
I looked up some articles but I'm not seeing much that sounds like what I am
trying to do.

"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Jameson" <mr********@gmail.comschrieb
>...is this possible?

You'd better put the question in the body not in the subject line.

Answer: Yes. Call the form's invoke/begininvoke method. In the procedure
called by invoke/begininvoke, add the control.
Armin





Jun 27 '08 #5
"Jameson" <mr********@gmail.comschrieb
Small example maybe?
I looked up some articles but I'm not seeing much that sounds like
what I am trying to do.

"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Jameson" <mr********@gmail.comschrieb
...is this possible?
You'd better put the question in the body not in the subject line.

Answer: Yes. Call the form's invoke/begininvoke method. In the
procedure called by invoke/begininvoke, add the control.

f.Invoke(New MethodInvoker(AddressOf f.YourMethod))

while f is the Form reference, and YourMethod is the method adding the
control. However, I'd raise a neutral event instead that is handled by the
Form and excutes the line above (replace 'f' by 'Me'). One shouldn't care
about the UI in a worker thread (IMO).
Armin

Jun 27 '08 #6
MainForm.Invoke(New MethodInvoker(AddressOf MainForm.Controls.Add))

Yeah that doesn't work and I know it's not what you told me to do, lol I'm
sorry. Its as if I am wanting to do this.
I have form1, it is going to do some calculations for a bit, I cannot escape
that fact as form1 is my main application form. What I want to do is create
a new thread that will add a control to form1 (that covers the entire form)
and display a bussy animation. Problem is VB wont let me add a control to a
form on a different thread. I'm certain what you gave me will work I guess
I just do not understand what I am supposed to do.

This is my code, Mainform is essentially form1 as described above.

'simple code to display bussy notification
Public mrg_p As wait
Private t As Threading.Thread

Public Sub show_bussy()
t = New Threading.Thread(AddressOf bussy)
t.Start()
End Sub
Private Sub bussy()
If mrg_p IsNot Nothing Then mrg_p.Dispose()
mrg_p = New wait
'MainForm.Controls.Add(mrg_p)
' f.Invoke(New MethodInvoker(AddressOf f.YourMethod))
MainForm.Invoke(New MethodInvoker(AddressOf MainForm.Controls.Add))

MainMarque.Visible = False
With mrg_p
.Top = 0
.Left = 0
.Dock = DockStyle.Fill
End With
MakeWindowAlwaysTop(mrg_p.Handle.ToInt32)
mrg_p.Show()
mrg_p.Visible = True
End Sub

Public Sub hide_bussy()
t.Abort()
End Sub

"Armin Zingler" <az*******@freenet.dewrote in message
news:OT**************@TK2MSFTNGP06.phx.gbl...
"Jameson" <mr********@gmail.comschrieb
>Small example maybe?
I looked up some articles but I'm not seeing much that sounds like
what I am trying to do.

"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Jameson" <mr********@gmail.comschrieb
...is this possible?

You'd better put the question in the body not in the subject line.

Answer: Yes. Call the form's invoke/begininvoke method. In the
procedure called by invoke/begininvoke, add the control.


f.Invoke(New MethodInvoker(AddressOf f.YourMethod))

while f is the Form reference, and YourMethod is the method adding the
control. However, I'd raise a neutral event instead that is handled by the
Form and excutes the line above (replace 'f' by 'Me'). One shouldn't care
about the UI in a worker thread (IMO).
Armin
Jun 27 '08 #7
Well I tried this...Which worked but it defeats the purpose because it
places the control under mainform's thread instead of the new one I made and
the animation doesn't run, also the thread abort command never fires.
Private Sub bussy()
If mrg_p IsNot Nothing Then mrg_p.Dispose()
mrg_p = New wait
'MainForm.Controls.Add(mrg_p)
' f.Invoke(New MethodInvoker(AddressOf f.YourMethod))
MainForm.Invoke(New MethodInvoker(AddressOf add_bussy))
MainMarque.Visible = False
With mrg_p
.Top = 0
.Left = 0
.Dock = DockStyle.Fill
End With
MakeWindowAlwaysTop(mrg_p.Handle.ToInt32)
mrg_p.Show()
mrg_p.Visible = True
End Sub
Private Sub add_bussy()
MainForm.Controls.Add(mrg_p)
End Sub
"Armin Zingler" <az*******@freenet.dewrote in message
news:OT**************@TK2MSFTNGP06.phx.gbl...
"Jameson" <mr********@gmail.comschrieb
>Small example maybe?
I looked up some articles but I'm not seeing much that sounds like
what I am trying to do.

"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"Jameson" <mr********@gmail.comschrieb
...is this possible?

You'd better put the question in the body not in the subject line.

Answer: Yes. Call the form's invoke/begininvoke method. In the
procedure called by invoke/begininvoke, add the control.


f.Invoke(New MethodInvoker(AddressOf f.YourMethod))

while f is the Form reference, and YourMethod is the method adding the
control. However, I'd raise a neutral event instead that is handled by the
Form and excutes the line above (replace 'f' by 'Me'). One shouldn't care
about the UI in a worker thread (IMO).
Armin
Jun 27 '08 #8

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

Similar topics

2
by: RBohannon | last post by:
Is it possible to create a control array on an unbound form? I would like to be able to loop through a series of unbound text boxes. Thanks.
4
by: MLH | last post by:
From FormA or from the immediate window, what can I run to determine if a specified control (say, "MyComboBox") exists on FormB (or ReportB)? We could narrow it down, specifying that FormB (or...
9
by: David Sworder | last post by:
Hi, I have a form that displays data (is that vague enough for you?). The data comes in on a thread-pool thread. Since the thread pool thread is not the same as the UI thread, the callback...
5
by: Dan | last post by:
Good Day All, I am having a problem in Visual Studio 2005 Beta 2. I am hoping someone might have an idea as to what is going on. I have an ActiveX User Control written using Visual Basic 6.0....
6
by: Tom Rowton | last post by:
This one has me a bit confused and I'm not finding what I need in the MSDN or by searching these forums, so here goes... I have a rather large, complex code-in-page WebForm (don't ask) and a...
2
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2...
1
by: Rahim | last post by:
i want to change all the label control style Properties, server control properties at runtime how should i call all the label at runtime, which is present at webform, any collections???? i...
3
by: JamesB | last post by:
Hello I have a form which contains a Listview control that is filled with data as the program runs. This all works fine, but I want to also then do a certain process on this data at the same...
3
by: timothyriggs | last post by:
Building a CRM in Access 2007 with a MySQL backend. Have several objects defined, one of which is the Customer object, another is the Jobs object. The Customer object has a collection of Jobs...
1
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...
0
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
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
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...
1
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
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.