473,322 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

open form in Thread

how to open an form in an thread
and pass an object in the constructor ??
Nov 16 '05 #1
3 8418
Hi,

You should interact with the UI only from the main thread, what you can do
is create a delegate and fire an event to be executed on the UI thread,
there you can open a new window with no problem.

You can inherit from EventArgs to add the object you need to pass to the
event.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"LiFo" <ik****@hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
how to open an form in an thread
and pass an object in the constructor ??

Nov 16 '05 #2
Hi, LiFo

You can use Form.ShowDialog as usual on any thread. But you might have to
ensure dialog will be shown not behind some other window, which might happen
to be active at that moment.

If you want to show standard form, you might do this with Application.Run on
it. It will work Ok if there is no interaction with forms on other threads,
including UI. Otherwise, you'll have to resort to Invoke methods and
InvokeRequired checks.

You don't need to pass objects in constructors. Just add some set property
in the form, create it with new and set object to property.
If you want to pass object to thread - see MSDN
http://msdn.microsoft.com/library/de...ingThreads.asp

HTH
Alex

"LiFo" <ik****@hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
how to open an form in an thread
and pass an object in the constructor ??

Nov 16 '05 #3
i have tryed to make an methode in MainForm that makes an form and shows it
and pass an delegate to the class that is supposed to show the form

but no diffrence when i call the delegate the form shows up and freezes
but if i use ShowDialog() it shows up fine
??

so i am going to try with an thread
"LiFo" <ik****@hotmail.com> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
how to open an form in an thread
and pass an object in the constructor ??

Nov 16 '05 #4

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

Similar topics

6
by: D Witherspoon | last post by:
My application takes 5 or 6 seconds to load because of the time required to communicate with web services and load from the database. In the meantime I'd like to show a splash screen in a seperate...
3
by: MrNobody | last post by:
I'm pretty tired from working all day on this program and this one simple task of showing a certain form when the app initializes is driving me nuts... It opens very briefly then quickly...
5
by: MrNobody | last post by:
I am using the no-arg ShowDialog() method hoping that the window would not be modal to any other window like the other ShowDialog(IWin32Window) method does, but when this opens it somehow becomes...
2
by: Sgt. Sausage | last post by:
New to multi-threading (less than 24 hours at it <grin>) Anyway, it's all making sense, and working fairly well thus far, but I'm having a minor issue I'm not sure how to get around. I've got...
3
by: stumorgan | last post by:
There is probably an extremely simple answer to this question and I'm just being foolish. I have a main form (let's say FormMain) which opens other forms (let's say Form1, Form2). How do I keep...
29
by: Bryce K. Nielsen | last post by:
Suddenly this week, I've started getting this error message: System.Data.SqlClient.SqlConnection(GetOpenConnection)ExecuteNonQuery requires an open and available Connection. The connection's...
2
by: abid gee | last post by:
Please give a kind look on my question. and please comments. I am Using C# as development tool of Dot Net 2.0. I wrote a function read_data() that read data from Serial Port continuously.Till...
5
by: BD | last post by:
I am coding with C# in Visual Studio 2005 for a database application residing on remote MS SQL Server 2005. What I want to do is open the same form but from 2 different places and only one...
2
by: pandehrushikesh | last post by:
I am doing setup project in VS 2008. I used custom action to select file from local drives. On the button click of custom action form, I am launching Open file dialog as ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.