I'm having difficulty figuring out how to translate a windows form application into a module. Essentially I want the program to run, and terminate without any UI (or any overhead of UI).
The problem is that my code relies upon a referenced COM object, which needs to be initialised, and then raises an event when it is ready to use. My simplified code for the windows form is shown below. ----------------------------------------------------------- Imports com_dll Public Class Form1 Private COM_OBJECT As Ctl Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load myCtl = New Ctl() AddHandler myCtl.EventReady, AddressOf EventReady End Sub Private Sub EventReady() ' Do stuff with initialised control Application.Exit End Sub End Class -------------------------------------------------------------- My thinking of converting it to a module would be along the lines of: ----------------------------------------------------------- Imports com_dll Module myModule Private COM_OBJECT As Ctl Public Sub main() myCtl = New Ctl() AddHandler myCtl.EventReady, AddressOf EventReady ' HOLD EXECUTION OF THIS SUB HERE TO ALLOW OTHER EVENTS TO BE RAISED AND EXECUTED Application.Exit End Sub Private Sub EventReady() ' Do stuff with initialised control End Sub End Module -------------------------------------------------------------- >From what I've read, DoEvents() is exactly what I need to suspend execution of the current Sub, and allow the system to respond to other events. However, it's not available from within a module. Does anyone have an alternative suggestion for ensuring the module doesn't terminate until the referenced COM events are raised and processed? Thanks Paul -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to dotnetdevelopment@googlegroups.com To unsubscribe from this group, send email to dotnetdevelopment+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net