OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Alex Shevchuk (ashevchukCORILLIAN.COM)
Date: Fri Mar 01 2002 - 10:56:34 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Mark,

    I don't think you need a message pump here.
    There is other thing though in your code.
    If your thread function is a member of the class
    it must be static member and you need to create
    an additional non-static method. Your code
    should look like:

    void __cdecl CLIGroup::CycleThread(void *parameter)
    {
        CLIGroup *ptr = (CLIGroup *)parameter;
        ptr->_CycleThread();
    }

    void _CycleThread()
    {
        // Here goes everything else and
        // here you can get access to member
        // variables, such as mSyncMarshalStream, etc.

    }

    Regards,

    Alex Shevchuk

    > -----Original Message-----
    > From: Mark A. Rice [mailto:mriceCANARYLABS.COM]
    > Sent: Friday, March 01, 2002 7:36 AM
    > To: DCOMDISCUSS.MICROSOFT.COM
    > Subject: Message pump in thread
    >
    >
    > This is a really basic question, but one that has escaped my
    > notice so far.
    > In the following thread, do I need to put in a message pump somewhere?
    >
    > Thanks,
    >
    > Mark A. Rice
    > Canary Labs, Inc.
    > http://www.canarylabs.com
    >
    >
    > void __cdecl CLIGroup::CycleThread(void *parameter)
    > {
    > USES_CONVERSION;
    >
    > CLIGroup *ptr;
    > ptr = (CLIGroup *)parameter;
    >
    > HRESULT hRes = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    > _ASSERTE(SUCCEEDED(hRes));
    >
    > // Marshal the IOPCSyncIO interface from the stream.
    > CComPtr <IOPCSyncIO> syncIO;
    > hRes = CoGetInterfaceAndReleaseStream (ptr->mSyncMarshalStream,
    > IID_IOPCSyncIO, (void**)&syncIO);
    > _ASSERTE(SUCCEEDED(hRes));
    > if (FAILED(hRes)) {
    > ATLTRACE (_T("\nCould not un-marshal IOPCSyncIO
    > interface. Error
    > code 0x%X\n"), hRes);
    > }
    >
    > while (true) {
    > wait = WaitForSingleObject(ptr->mTerminateEvent, timeOut);
    > if (wait == WAIT_OBJECT_0)
    > break; // We're Done
    > else
    > // Try reading some OPC Data
    > if (syncIO)
    > ptr->ReadCurrentValues(syncIO);
    > }
    >
    > // Free the interface.
    > syncIO.Release();
    >
    > // Free the COM library.
    > CoUninitialize( );
    >
    > ptr->mThread = -1;
    > SetEvent (ptr->mDoneTerminatingEvent);
    > _endthread();
    > }
    >
    > ----------------------------------------------------------------
    > Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    > contains important info. Save time, search the archives at
    > http://discuss.microsoft.com/archives/index.html .
    > To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM
    >

    ----------------------------------------------------------------
    Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM