Here is my code. It sits forever, does not ever raise an event. What am I doing wrong? I suspect I am using the ManualWaitEvent wrong.
Thank you.Code:Imports System.Threading Module Module1 Dim addevent As ManualResetEvent Dim WithEvents faxsvr As FAXCOMEXLib.FaxServer Dim jobstatus As FAXCOMEXLib.FaxJobStatus Sub Main() Try faxsvr = New FAXCOMEXLib.FaxServer faxsvr.Connect("sbs2k8") faxsvr.ListenToServerEvents(FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED Or FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE) addevent = New ManualResetEvent(False) addevent.WaitOne() 'If the fax service is stopped - > faxsvr_OnServerShutdown() will be called. 'If something is added to the outgoing queue - > faxsvr_OnOutgoingJobAdded() will be called. 'If the status of the outgoing job changes -> faxsvr_OnOutgoingJobChanged() gets called. Catch ex As Exception MsgBox(ex.ToString()) End Try Console.WriteLine("Waiting for thread..") End Sub Private Sub faxsvr_OnOutgoingJobAdded(ByVal pFaxServer As FAXCOMEXLib.IFaxServer, ByVal bstrJobId As String) Console.WriteLine("++ New outgoing fax added to queue.") addevent.Set() End Sub Private Sub faxsvr_OnOutgoingJobChanged(ByVal pFaxServer As FAXCOMEXLib.IFaxServer, _ ByVal bstrJobId As String, ByVal pJobStatus As FAXCOMEXLib.IFaxJobStatus) 'This event receives the FaxJobStatus object 'Since this event is likely to result in errors, such as trying to 'report the transmission end time before the transmission has ended, 'this subroutine includes error handling 'Error handling Try 'Display the FaxJobStatus object's properties when the event is called Console.WriteLine(pJobStatus.AvailableOperations, "\nCaller ID: " & pJobStatus.CallerId & _ "\nCSID: " & pJobStatus.CSID & _ "\nCurrent page: " & pJobStatus.CurrentPage & _ "\nDevice ID: " & pJobStatus.DeviceId & _ "\nExtended status: " & pJobStatus.ExtendedStatus & _ "\nExtended status code: " & pJobStatus.ExtendedStatusCode & _ "\nJob type: " & pJobStatus.JobType & _ "\nPages: " & pJobStatus.Pages & _ "\nRetries: " & pJobStatus.Retries & _ "\nRouting information: " & pJobStatus.RoutingInformation & _ "\nScheduled time: " & pJobStatus.ScheduledTime & _ "\nSize: " & pJobStatus.Size & _ "\nStatus: " & pJobStatus.Status & _ "\nTransmission start: " & pJobStatus.TransmissionStart & _ "\nTSID: " & pJobStatus.TSID) 'Display the transmission end time separately, as this will cause an error 'while the transmission is still in progress Console.WriteLine("Transmission end: " & pJobStatus.TransmissionEnd) Catch ex As Exception End Try addevent.Set() End Sub Private Sub faxsvr_OnServerShutDown(ByVal pFaxServer As FAXCOMEXLib.IFaxServer) Console.WriteLine("-- The local fax server has been shut down") addevent.Set() End Sub End Module




Reply With Quote