I need to call ShowDialog()
on my Form
without it actually displaying the dialog (keep Visible
set to false
). Unfortunately, there is no VisibleChanged
event like there is on the full framework. I also can't override the the Visible
property. The closest I can come up with is to override OnLoad
and call Hide
in a new thread (since the form's visibility is set after it is loaded). This is obviously a crazy hack (not to mention is looks really bad since you can see a form being drawn and then hidden on the screen) but I really can't seem to figure out another way to do this. Any ideas?
Edit: I need to call ShowDialog()
because I'm working with a buggy third party library which only works when invoked within a form like this and in my scenario I have no need or desire for any UI. I've confirmed the bug with the third party but they don't currently have any resources to fix the issue so I'm stuck with some crazy workaround this.
Edit2: Here's some more specific info about my issue:
This works:
MyForm_OnLoad(...)
{
thirdPartyLib.StartUp(MyCallback);
}
private void MyCallback(...)
{
// Do some work with the data passed in.
}
This does not:
public static void Main()
{
thirdPartyLib.StartUp(MyCallback);
// Sleep for a bit to allow the library to fire the callback.
// Normally, the callback is triggered several times a second.
Thread.Sleep(20000);
}
private void MyCallback(...)
{
// This callback is never invoked by the library.
}
So the only way I can get things to work is by using the library in a Form
. Unfortunately I don't want to display a form in my application so I'm trying to use the form to appease the library but not display anything to accommodate my application. I'm open to suggestions.
Note that the compact framework winforms API does not support opacity nor does it have an OnShown
event (nor VisibleChanged
).
Edit3: Sorry guys, I'm not intending to be vague I just didn't want to get lost in details that didn't seem relevant. The third party library captures images from a special camera hooked up via USB. The callback function gets fired with a couple different parameters to indicate the current status and image data from the camera.