473,387 Members | 1,942 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,387 software developers and data experts.

Creating Forms in a Callback

I've posted this question before, and since then I've tried a variety of
work-arounds, with no success. So, here goes again...

I'd like to create forms and open them from within a callback function
in managed code. To be more specific, when I connect my USB device, I'd
like the driver, implemented in unmanaged code, to call a callback in
managed.
I have the callback working, but when I try to create and open a new
form to interface with this device, the form starts to open but turns
all white. Then I get an hour-glass of death. I have to stop the app to
recover.

Note that if I use the OpenDialog instead of the Open form method, then
the form opens ok, but this is not acceptable. I need the form to stay
open. I may have multiple USB devices connected.

Any help?

Thanks in advance for the help,
Best Regards,
Dennis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
1 1448
If you are really sure you want to run UI stuff on the non main UI thread,
you have to consider that all UI threads needs:
- to pump messages,
A message pump is created by calling Application.Run, so you need to
call Application.Run(...) passing a reference to your form as argument.
- need an STA to run on.
Your callback runs on a threadpool thread which is by default MTA
initialized , so you need to start another thread from the callback set the
thread apartment to STA and start the message pump on this thread.
- non UI threads needs to pass messages to the right UI thread when touching
UI interface elements.
Willy.

"Dennis Burns" <db****@rtessentials.com> wrote in message
news:eD**************@TK2MSFTNGP10.phx.gbl...
I've posted this question before, and since then I've tried a variety of
work-arounds, with no success. So, here goes again...

I'd like to create forms and open them from within a callback function
in managed code. To be more specific, when I connect my USB device, I'd
like the driver, implemented in unmanaged code, to call a callback in
managed.
I have the callback working, but when I try to create and open a new
form to interface with this device, the form starts to open but turns
all white. Then I get an hour-glass of death. I have to stop the app to
recover.

Note that if I use the OpenDialog instead of the Open form method, then
the form opens ok, but this is not acceptable. I need the form to stay
open. I may have multiple USB devices connected.

Any help?

Thanks in advance for the help,
Best Regards,
Dennis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2

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

Similar topics

0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
0
by: Hector | last post by:
I have a ComboBox set up in a non-modal form. When a selection is made from the ComboBox, the handler code closes the form, but then the system crashes because of an unhandled NullReferenceException....
2
by: Dion Heskett | last post by:
Hi I get a InvalidOperationException message when I click button2 at this line of code textBox1.Text = whoIs1.EndLookup( asyncResult ); Should I now be implementing the BackgroundWorker Class...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
6
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns...
0
by: =?Utf-8?B?c2Vy?= | last post by:
Hi, I am working on a windows application whose primary task is to apply all the properties of one control to another. Hence i am using the SetValue method of the PropertyDescriptor. The...
0
by: =?Utf-8?B?TWFyaw==?= | last post by:
Users of an in-house application we have written randomly get an Error creating window handle exception, and we've not been able to determine why this happens. A typical callstack is as follows: ...
0
by: austincolby | last post by:
I am working on creating a SOAP client in Visual Studio 2008 for the first time but am running into a few issues. I added the Web Service reference to the project and am able to see the namespace...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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...

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.