Thread and COM Object.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sam Davis

    Thread and COM Object.

    I have a COM object that manages a phone line. The COM Object has an Event
    OnRingDetected( ) which is called when someone calls the phone line this COM
    object is monitoring. When the OnRingDetected is called it is supposed to
    kick off a process that executes a script. I would like this all in a service
    that is capable of doing this for multiple phone lines. I was thinking of
    placing these objects in a thread but how do you tell the thread not to
    terminate while the COM Object is waitng for a call to come in??? Any ideas.
    My brain is just fried today.. Thanks for any help!
  • John Sun

    #2
    Re: Thread and COM Object.



    keep a while loop to check some conditions before allowing a thread to exit.

    while ( bConditon)
    {
    // do your stuff.
    }

    This is a typical service structure. You could also use
    WaitForSingleOb ject of WaitForMultiple Objects to watch for some events.

    There are a lot of samples codes if you google.

    Sam Davis wrote:[color=blue]
    > I have a COM object that manages a phone line. The COM Object has an Event
    > OnRingDetected( ) which is called when someone calls the phone line this COM
    > object is monitoring. When the OnRingDetected is called it is supposed to
    > kick off a process that executes a script. I would like this all in a service
    > that is capable of doing this for multiple phone lines. I was thinking of
    > placing these objects in a thread but how do you tell the thread not to
    > terminate while the COM Object is waitng for a call to come in??? Any ideas.
    > My brain is just fried today.. Thanks for any help![/color]

    Comment

    • Sam Davis

      #3
      Re: Thread and COM Object.

      Thanks John. I thought of the while but was concerned for CPU utilization. I
      changed my thought process a little. I left the object out of a thread and
      just threaded the processing once the call came in. So far it seems ok, until
      I have multiple lines running. :)

      "John Sun" wrote:
      [color=blue]
      >
      >
      > keep a while loop to check some conditions before allowing a thread to exit.
      >
      > while ( bConditon)
      > {
      > // do your stuff.
      > }
      >
      > This is a typical service structure. You could also use
      > WaitForSingleOb ject of WaitForMultiple Objects to watch for some events.
      >
      > There are a lot of samples codes if you google.
      >
      > Sam Davis wrote:[color=green]
      > > I have a COM object that manages a phone line. The COM Object has an Event
      > > OnRingDetected( ) which is called when someone calls the phone line this COM
      > > object is monitoring. When the OnRingDetected is called it is supposed to
      > > kick off a process that executes a script. I would like this all in a service
      > > that is capable of doing this for multiple phone lines. I was thinking of
      > > placing these objects in a thread but how do you tell the thread not to
      > > terminate while the COM Object is waitng for a call to come in??? Any ideas.
      > > My brain is just fried today.. Thanks for any help![/color]
      >[/color]

      Comment

      Working...