by darchangel » Fri Jun 15, 2007 7:14 am
Here are some more attempts at getting a .net winform to receive mm events:
WHAT DIDN'T WORK
try 1 auto launch script to launch winform and subscribe to events. delegate events to a method in the app
problem GetObject doesn't seem to get the currently running version of the winform. error is thrown. CreateObject also yields wrong results
try 2 same as #1 but make the winform single instance so CreateObject will always get the correct version
problem the only way I can figure out how to make an app single instance involves using the static Main() for much of the work. CreateObject bypasses Main and only calls constructor
try 3 same as #1 but use threading and Invoke/BeginInvoke to fire winform method
problem error about not being able to use Invoke/BeginInvoke without having a handle to the window. unsure how to do this in vbscript. again, GetObject didn't work here in trying to resolve it
WHAT WORKED (BUT SUCKS)
solution auto launch script registers for events and launches the winform. event methods create temp files when events are fired. (note: at the beginning of the onstart, delete old files or future runs will think that these events are new). the winform has a file system watcher (available in .net 2.0) which reacts to the file creation and deletes the files sequentially
why it sucks using files as events is simply lame. i also did a version where only 1 file was used but you come into IO collisions/exceptions when too many events happen too quickly. also, keeping the files in order when events fire quickly is more advanced than just using a timestamp with seconds as the greatest granularity
solution launch 2 .net apps: 1 winform, 1 console. the console one can handle events just fine. so set up a cross process connection between them either via .net remoting or through socket connections and have the console app delegate the events to the winform
why it sucks way too much overhead. and i refuse to keep a client server relationship on the same box just to delegate event callls
Here are some more attempts at getting a .net winform to receive mm events:
WHAT DIDN'T WORK
[b]try 1[/b] auto launch script to launch winform and subscribe to events. delegate events to a method in the app
[u]problem[/u] GetObject doesn't seem to get the currently running version of the winform. error is thrown. CreateObject also yields wrong results
[b]try 2[/b] same as #1 but make the winform single instance so CreateObject will always get the correct version
[u]problem[/u] the only way I can figure out how to make an app single instance involves using the static Main() for much of the work. CreateObject bypasses Main and only calls constructor
[b]try 3[/b] same as #1 but use threading and Invoke/BeginInvoke to fire winform method
[u]problem[/u] error about not being able to use Invoke/BeginInvoke without having a handle to the window. unsure how to do this in vbscript. again, GetObject didn't work here in trying to resolve it
WHAT WORKED (BUT SUCKS)
[b]solution[/b] auto launch script registers for events and launches the winform. event methods create temp files when events are fired. (note: at the beginning of the onstart, delete old files or future runs will think that these events are new). the winform has a file system watcher (available in .net 2.0) which reacts to the file creation and deletes the files sequentially
[u]why it sucks[/u] using files as events is simply lame. i also did a version where only 1 file was used but you come into IO collisions/exceptions when too many events happen too quickly. also, keeping the files in order when events fire quickly is more advanced than just using a timestamp with seconds as the greatest granularity
[b]solution[/b] launch 2 .net apps: 1 winform, 1 console. the console one can handle events just fine. so set up a cross process connection between them either via .net remoting or through socket connections and have the console app delegate the events to the winform
[u]why it sucks[/u] way too much overhead. and i refuse to keep a client server relationship on the same box just to delegate event callls