Re: Problem understanding asynchronous processes
From: Larry Daugherty (Larry.NoSpam.Daugherty_at_verizon.net)
Date: 03/05/05
- Next message: Larry Daugherty: "Re: How do I make a Button locate a report with a specifc Id Number? ."
- Previous message: Larry Daugherty: "Re: NEW record, another table, using Form"
- In reply to: Browser: "Problem understanding asynchronous processes"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 5 Mar 2005 11:35:48 -0800
I think your issue is more in the sphere of ActiveX than of Access.
HTH
-- -Larry- -- "Browser" <Browser@discussions.microsoft.com> wrote in message news:D8BB3C51-6548-4FA4-8C0E-7F066EC97D92@microsoft.com... > Hello, > > I'm new to VBA and am having a problem understanding asynchronous processes. > > I've a Form in Access that I want to start an out-of-process object that > will run, basically, on its own until stopped by an outside event. > > My problem is that I don't understand how to start the object without > getting the Form caught waiting for the object to stop processing. > > What I've done is create an ActiveX EXE component that houses two class > objects, one that does the work (called the FNCreator) and a wrapper class > (called the Creator). > > In my Access form I create an instance of the Creator class and tell it to > create an instance of the FNCreator. When the Creator does this, it passes a > reference to itself, with events, to the FNCreator. > > To start the FNCreator, the Access form calls Creator.Start. Creator.Start > then raises an event StartIt which is handled in FNCreator. > > I thought that Creator.Start would fire the event and go to the next > instruction without jumping to FNCreator's StartIt() handler, but that is not > what happens. Instead Creator.Start gets caught waiting for the sub called by > the event to end and therefore doesn't return control to the Access form. How > would I implement this correctly? > > I'd love to hear if anyone has a helpful suggestion or can point me in the > right direction for assisatance. Thanks! > > My simplified code looks like this: > > Access Form: > > Private Sub Toggle0_Click() > > If Toggle0.Value = True Then > ... > Set myCreator = New Creator > ... > myCreator.create "FN" > ... > myCreator.start "FN" > Else > myCreator.ShutDown "FN" > End If > > End Sub > > > Creator Class: > > Private myFNCreator As FNCreator > > Event FNStartIt() > Event FNStopIt() > > Public Function Create(arg As String) > > Select Case arg > Case "FN" > If Not myFNCreator Is Nothing Then > ... > Else > Set myFNCreator = New FNCreator > Set myFNCreator.Parent = Me > ... > End If > Case Else > ... > End Select > End Function > > Public Function Start(arg As String) > > Select Case arg > Case "FN" > If Not myFNCreator Is Nothing Then > If myFNCreator.Active = False Then RaiseEvent FNStartIt > Else > ... > End If > Case Else > ... > End Select > End Function > > Public Function ShutDown(arg As String) > > Select Case arg > Case "FN" > If Not myFNCreator Is Nothing Then > ... > RaiseEvent FNStopIt > Else > ... > End If > Case Else > ... > End Select > End Function > > > FNCreator Class: > > Private booIsActive As Boolean > Private WithEvents myParent As Creator > > Private Sub Class_Initialize() > > booIsActive = False > > End Sub > > Private Sub Class_Terminate() > > If Not myRecordset Is Nothing Then Set myRecordset = Nothing > > End Sub > > Friend Property Get Active() As Boolean > > Active = booIsActive > > End Property > > Friend Property Set Parent(arg As Creator) > > Set myParent = arg > > End Property > > Public Sub myParent_FNStartIt() > > If booIsActive = True Then Exit Sub > booIsActive = True > ... > > Do While booIsActive = True > ... > Loop > ... > End Sub > > Public Sub myParent_FNStopIt() > > booIsActive = False > > End Sub > >
- Next message: Larry Daugherty: "Re: How do I make a Button locate a report with a specifc Id Number? ."
- Previous message: Larry Daugherty: "Re: NEW record, another table, using Form"
- In reply to: Browser: "Problem understanding asynchronous processes"
- Messages sorted by: [ date ] [ thread ]