473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing a form from within a thread

I have the following which generates MDI forms, but doesn't show them at
this stage:

For n As Integer = 1 To 10

fmViewer(n) = New frmViewer

fmViewer(n).Tag = n

fmViewer(n).Mdi Parent = Frm1

Next

From within a new thread I wish to show a form:

fmViewer(4).sho w

However, it doesn't show. The answer I am sure is because I am trying to
show it from within a thread. How can I achieve this?

-Jerry


Aug 6 '06 #1
5 1219
is fmViewer an array? or are you trying to do something else....please
explain a little bit more
--
-iwdu15
Aug 6 '06 #2
Jerry Spence1 wrote:
I have the following which generates MDI forms, but doesn't show them at
this stage:

For n As Integer = 1 To 10

fmViewer(n) = New frmViewer

fmViewer(n).Tag = n

fmViewer(n).Mdi Parent = Frm1

Next

From within a new thread I wish to show a form:

fmViewer(4).sho w

However, it doesn't show. The answer I am sure is because I am trying to
show it from within a thread. How can I achieve this?
What is frmViewer? Here you are using it as both the name of your
class and the name of the array variable. Can you show us the
declaration for frmViewer?

Chris

Aug 7 '06 #3
Jerry,

All Form access must be done from the main UI thread. That includes
creating, manipulating, and showing the Form. You'll need a reference
to an existing Form or Control that your worker thread will use to
marshal the execution of a delegate onto the UI thread by calling
Invoke or BeginInvoke. That delegate should contain the code to create
and show the new Form. Invoke and BeginInvoke are among the very few
members of a Form or Control that are actually thread-safe.

Brian

Jerry Spence1 wrote:
I have the following which generates MDI forms, but doesn't show them at
this stage:

For n As Integer = 1 To 10

fmViewer(n) = New frmViewer

fmViewer(n).Tag = n

fmViewer(n).Mdi Parent = Frm1

Next

From within a new thread I wish to show a form:

fmViewer(4).sho w

However, it doesn't show. The answer I am sure is because I am trying to
show it from within a thread. How can I achieve this?

-Jerry
Aug 7 '06 #4
Hi Chris

fmViwer is the name of my form, fmViewer() is an array. I can see the
difference is rather small!

-Jerry
"Chris Dunaway" <du******@gmail .comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
Jerry Spence1 wrote:
>I have the following which generates MDI forms, but doesn't show them at
this stage:

For n As Integer = 1 To 10

fmViewer(n) = New frmViewer

fmViewer(n).Ta g = n

fmViewer(n).Md iParent = Frm1

Next

From within a new thread I wish to show a form:

fmViewer(4).sh ow

However, it doesn't show. The answer I am sure is because I am trying to
show it from within a thread. How can I achieve this?

What is frmViewer? Here you are using it as both the name of your
class and the name of the array variable. Can you show us the
declaration for frmViewer?

Chris

Aug 7 '06 #5

"Brian Gideon" <br*********@ya hoo.comwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Jerry,

All Form access must be done from the main UI thread. That includes
creating, manipulating, and showing the Form. You'll need a reference
to an existing Form or Control that your worker thread will use to
marshal the execution of a delegate onto the UI thread by calling
Invoke or BeginInvoke. That delegate should contain the code to create
and show the new Form. Invoke and BeginInvoke are among the very few
members of a Form or Control that are actually thread-safe.

Brian

Jerry Spence1 wrote:
>I have the following which generates MDI forms, but doesn't show them at
this stage:

For n As Integer = 1 To 10

fmViewer(n) = New frmViewer

fmViewer(n).Ta g = n

fmViewer(n).Md iParent = Frm1

Next

From within a new thread I wish to show a form:

fmViewer(4).sh ow

However, it doesn't show. The answer I am sure is because I am trying to
show it from within a thread. How can I achieve this?

-Jerry
Thanks Brian. I'll have a look at Invoke and BeginInvoke.

-Jerry
Aug 7 '06 #6

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

Similar topics

2
3413
by: Krzysztof Karnicki | last post by:
I would like develop Form on my Windows Application, that is going to notify the user, just like Microsoft Office 2003 shows that there are new mail coming. When I use System.Windows.Forms.Form and show it on a different then main thread on my application, this new form became focused, but I want that new form at the beginning acts like just stay-on-top notification… also in this form I would like have controls, that could be focused,...
2
2494
by: Sharon | last post by:
I have a Form class that can be open by parent Form or by .NET Remoting command. When the parent Form opens the Form - All fine ! But when the .NET Remoting command is trying to Show the Form, the Form stuck !! I tried to change the Remoting delegate invocation to asynchronous and to synchronous, yet both cause the same Form Show() to stuck. When I mean stuck, I mean the the Form is shown but non of it controls are shown, only gray window...
8
3279
by: Raed Sawalha | last post by:
I have form with progress bar ,when application begin processing and progress bar moving if I minimized the form and try to restore it ,it is not showing until the processing completed ,how can I enabled minimize, maximize moving form while processing in underway?
0
906
by: BergRD | last post by:
For some odd reason my original post was double posted then removed from the forums. Odd happenings but wanted to re-post incase no one saw the original, thanks :D > Salutations! > > New to the forums but have gotten many an idea from lurking over the past few months but alas it's time to begin positing; posting to a problem I cannot seem to resolve. This is a long description but my hopes are the more information the better someone...
3
3695
by: EnglishMan69 | last post by:
Hello All, I am using VB2005 Beta 2 in VS 2005 and am running into a small problem. I need to be able to add a picture box to the main form from within a thread. The program goes to a web site, performs a search based on POST variables, retrieves the code, parses the information (including a url for a thumbnail image) and displays the results. I am using threads, since the program will appear to freeze while
5
10908
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I have a form that has a button. ( this form is a child form of a parent form ( main form ). Anway...in this child form I have a button, and if clicked a bunch of code will get executed. I would like to show a Progress Bar / form in modal/ShowDialog...
2
2070
by: Lars Netzel | last post by:
Hi I have a Form that on Form_Load() does some heavy database reading and I want to show that as a progressbar ontop of the main window.. I want to create a smaller Form with a progressbar.. and then in the main form, start a new thread that opens that small form and for each progress the heavy operation send a new value to the small form thru an event. I have managed to run a function or a sub in another thread but I can't
1
1635
by: Claire | last post by:
Hi I need to set my main form as the owner of an error dialog box shown when there's an exception in a background thread. This is to make sure that the error form is closed down if the user pulls their security card while the error window is being shown. In visual studio 2003, my main form set a static "owner" variable within my frmWarning class definition and if the error form was needed (and null owner passed) then this static variable...
7
1959
by: =?Utf-8?B?TWF0dA==?= | last post by:
Hi I have an app that runs without a main form, just a notification icon, when the user clicks the icon the form is shown, and when the form is minimized it's hidden. This all works great, and I have implemented single instance so that when another instance is run, an event gets signalled in the 1st instance, and what I would like to do is to show the form. I can do this using Form.Invoke to show the form in most cases, however at...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
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...
1
10038
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
9911
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
8934
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
6713
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
5354
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...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.