Posted to tcl by patthoyts at Sun Feb 15 11:01:30 GMT 2009view raw

  1. # Load up some CLR core sections
  2. import clr
  3. clr.AddReference('System')
  4. clr.AddReference('System.Windows.Forms')
  5. from System import *
  6. from System.Reflection import *
  7. from System.Threading import *
  8. from System.Windows.Forms import Application
  9. from time import sleep
  10.  
  11. # Create and launch the application on a second thread.
  12. # This prevents the application from blocking the console.
  13. #
  14. def RunCallback():
  15. global App
  16. asm = Assembly.LoadFrom('Renishaw Assay Reader.exe')
  17. asm_type = asm.GetType('D3UserInterface.MainForm')
  18. App = Activator.CreateInstance(asm_type)
  19. Application.Run(App)
  20.  
  21. def LaunchApp:
  22. tid = Thread(ThreadStart(RunCallback))
  23. tid.ApartmentState = ApartmentState.STA
  24. tid.Start()
  25. while not App:
  26. sleep(0.2)
  27. return tid