473,657 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ 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 1548
"Jameson" <mr********@gma il.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********@gma il.comschreef in bericht
news:90******** *************** ***********@mic rosoft.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******** ******@TK2MSFTN GP02.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********@gma il.comschreef in bericht
news:90******** *************** ***********@mic rosoft.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*******@free net.dewrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
"Jameson" <mr********@gma il.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********@gma il.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*******@free net.dewrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
"Jameson" <mr********@gma il.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(A ddressOf 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(A ddressOf MainForm.Contro ls.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.Threa d

Public Sub show_bussy()
t = New Threading.Threa d(AddressOf bussy)
t.Start()
End Sub
Private Sub bussy()
If mrg_p IsNot Nothing Then mrg_p.Dispose()
mrg_p = New wait
'MainForm.Contr ols.Add(mrg_p)
' f.Invoke(New MethodInvoker(A ddressOf f.YourMethod))
MainForm.Invoke (New MethodInvoker(A ddressOf MainForm.Contro ls.Add))

MainMarque.Visi ble = False
With mrg_p
.Top = 0
.Left = 0
.Dock = DockStyle.Fill
End With
MakeWindowAlway sTop(mrg_p.Hand le.ToInt32)
mrg_p.Show()
mrg_p.Visible = True
End Sub

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

"Armin Zingler" <az*******@free net.dewrote in message
news:OT******** ******@TK2MSFTN GP06.phx.gbl...
"Jameson" <mr********@gma il.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*******@free net.dewrote in message
news:%2******* *********@TK2MS FTNGP06.phx.gbl ...
"Jameson" <mr********@gma il.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(A ddressOf 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.Contr ols.Add(mrg_p)
' f.Invoke(New MethodInvoker(A ddressOf f.YourMethod))
MainForm.Invoke (New MethodInvoker(A ddressOf add_bussy))
MainMarque.Visi ble = False
With mrg_p
.Top = 0
.Left = 0
.Dock = DockStyle.Fill
End With
MakeWindowAlway sTop(mrg_p.Hand le.ToInt32)
mrg_p.Show()
mrg_p.Visible = True
End Sub
Private Sub add_bussy()
MainForm.Contro ls.Add(mrg_p)
End Sub
"Armin Zingler" <az*******@free net.dewrote in message
news:OT******** ******@TK2MSFTN GP06.phx.gbl...
"Jameson" <mr********@gma il.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*******@free net.dewrote in message
news:%2******* *********@TK2MS FTNGP06.phx.gbl ...
"Jameson" <mr********@gma il.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(A ddressOf 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
18601
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
3440
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 ReportB) would be opened in design view at the time of the inquiry.
9
7589
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 function of my form follows the standard design pattern: if(IsDisposed){ return; }
5
2628
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. Using Visual Studio 2005 I add the control to my Toolbox. I then drag the control onto a Panel control that is on a form. That is it. I don't write any code at all. When I run the program I get the following error:
6
6661
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 section of that Form is 4 or 5 ASP:Panels pretending to be a set of Tabs, each with its own section of the form.
2
3018
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 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
1
1464
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 can't remember each control name on the form. thanks help me
3
1443
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 time. Because of the way the data is received into the control (from an event out of my hands) my processing causes problems as it is time-intensive. So, I figure my processing should go in a separate thread so it can work without stopping the...
3
1451
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 objects in it's declarations. Customer calls in, user opens New Customer form and inputs the relevant contact information and a list of properties owned by the customer. Opening this form creates a new Customer Object. For each property entered...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.