CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    8

    Question ask about multi threading in DLL

    Hi,

    I would like to provide several C APIs. The APIs will be included in a dll on windows 32 platform, written in C.


    something like:

    1: open(char* ip, char* port, void *session)
    2: setvalue(void *session, double value)
    3: readvalue(void *session, double *value)
    4 close(void *session)


    the caller will open first to get a session, then it can setvalue or getvalue, then close the session.


    The problem is, for setvalue and readvalue, it will be called in a loop for 1000 or more times.

    like
    ************************

    open()

    for (int i =0; i< 1000; i++) {

    setvalue()

    do something

    getvalue()



    }

    close()


    *************************

    During the looping time, the client should send live message every certain period of time to keep the session live.

    This live message should also be included in the DLL. (the writer of the caller program doesn't need to care about this.)

    I don't know how I can implement the live message stuff ? What mechanism can be used to send the live message ?



    Any suggestion is welcome, thanks.
    Jerry

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: ask about multi threading in DLL

    As far as I understand, the dll must have some api which is intended for session initialization. Inside this init function the dll creates a watchdog thread transparently to api consumer. This thread implements 'live messaging'.

    Well, in fact the requirement of sending messages to keep session alive makes some sense only in case of client-server architecture, when the connection can be broken at any time with unpredictable period of recovery. In case the dll implements only some local stuff, live message requirement seems redundant (and leading to unnecessary complication). So, what case is yours?
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured