Using C# to create a GUI, plus threading

Mikee wrote on 10/27/2003, 2:47 PM
I've sucessfully implemented Sony PJM's Suggestion for calling a C# class.

My EntryFunction fires open a standard windows form using C# Application.Run method. This, I believe, blocks the main Vegas thread from responding to user input (ie click on tracks, selecting events, working with menus etc). Hovering over the Vegas app produces a wait-cursor, as expected. I believe PJM has good reason for doing this.

However, I'd like the form NOT to block the main Vegas app. Essentially, running the .js would fire the C# app, and the main thread in Vegas would continue like the .js script is done running. The C# app would be running in a Vegas "owned" thread. This is so the user can interact with vegas and the C# application concurrently.

I can sucessfully achieve letting Vegas continue by spinning off a new thread (via System.Threading) in the EntryFunction. The new thread opens the form with a reference to the original Project. However, my problem is that the passed in Project reference is no longer available after the EntryFunction completes and the .js is done running.

a) Is there anyway to maintain this project reference as passed in by the .js file, or reestablish it?
b) Maybe there is an easier method where the C# app runs outside of vegas. I really haven't investigated my options there yet.
c) Basically, I'm looking for an interactive method to work with Vegas while the script is running.

thank you,
Mike


Comments

aboukirev wrote on 10/28/2003, 9:40 AM
Have you tried calling Application.DoEvents() in the main thread so that it effectively would yield input/control to main application (instead of ending script)? Not sure if that works though.

Alexei
Mikee wrote on 10/28/2003, 1:40 PM
Thank you for the suggestion (Application.DoEvents)! ...but I doubt if it will work. The MSDN Docs seems to indicate it will make the Application process its own queued events.

It's really Vegas that is "hung" while the .js script is running. The proj reference is only valid while it is running so it seems to drop out of scope or is destroyed when the .js finishes. I can almost bet the main Vegas thread is suspended during the script execution due to concurrancy issues.
jbittner wrote on 11/3/2003, 5:04 PM
You are correct.

See the last couple of posts in the "Cancelling Render From Script" thread for more info.

Mikee wrote on 11/5/2003, 2:58 PM
JBittner,

Thanks for the helpful reply. For someone else's reference, the thread is located here.