473,320 Members | 2,083 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,320 software developers and data experts.

Running a form in another thread

Hi there,

I'm creating a form using the NativeWindow class to process some custom
messages. Unfortunately as it's created on the main thread of the
application it doesnt recieve messages while the thread is busy. So I'm
trying to create it on a separate thread. I can do this but the only way I
can keep the thread alive is by call Application.DoEvents. I'm not sure if
this is the correct way to do this as I'm presuming it processes all
messages to all forms in the application?

Is there any way I can create a form and keep it in a separate thread?
Thanks loads in advance.

--
Nick Pateman

---------------------------------------------------------------
Please do not reply directly to me, but the entire newsgroup.
Any views expressed above are my own
Without predjudice
Nov 21 '05 #1
2 3191
"Nick" <a@a.com> schrieb:
I'm creating a form using the NativeWindow class to process some custom
messages. Unfortunately as it's created on the main thread of the
application it doesnt recieve messages while the thread is busy. So I'm
trying to create it on a separate thread. I can do this but the only way
I can keep the thread alive is by call Application.DoEvents. I'm not sure
if this is the correct way to do this as I'm presuming it processes all
messages to all forms in the application?


Your second thread needs a separate message pump. You can call
'Application.Run' on the second thread to create a message pump. However,
note that forms and controls created in different threads cannot directly
interact with each other.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Hi Herfried,
Your second thread needs a separate message pump. You can call
'Application.Run' on the second thread to create a message pump. However,
note that forms and controls created in different threads cannot directly
interact with each other.


Thanks for your help :-) Most appreciated.

Nick.
Nov 21 '05 #3

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

Similar topics

1
by: Marc | last post by:
I want to write a C#/ASP.NET application where a user can go to a web page, start running a job, close their browser, and then come back later and see the results. The purpose for this application is...
13
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point,...
1
by: Dan | last post by:
Good Day, I have a Windows Service that is responsible for processing somes files. One method of the service invokes another method which may take a while to complete its work. Something like...
9
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
14
by: William LaMartin | last post by:
If I have a Windows application with no form--only a module that starts with sub main and which has a system timer, in the elapsed event of which I want to run some code, how can I keep this...
5
by: RWF | last post by:
I have a form, and from the form when a user clicks a button, it instantiates control that will be doing a lot of logic. I am trying to use System.Threading.ThreadPool.QueueUserWorkItem to spawn a...
9
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
0
by: peter palus | last post by:
Hi, I have a problem, how to cancel a running oracle-query. The situation: The user can type in a form, which kind of information he wants to now e.g. articletext like 'abc%'. This information...
5
by: mbewers1 | last post by:
I have a problem with this piece of code, which loads a splash screen and keeps it open for 5 seconds before loading another form. It strangely seems to be repeatedly running a thread once the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.