Announcement

Collapse
No announcement yet.

Best way to react to event?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best way to react to event?

    Hi,

    My applet replaces the mailslot that is open by the Messenger service (WinPopup in 9x), and waits for incoming messages.

    What is the best way to react to an event? Should I use a timer that calls a callback procedure every X seconds? Should I use a WHILE/WEND with a sleep() in the middle?

    CreateMailslot ()
    While app exists
    GetMailslotInfo ()
    If sthing to read
    ReadFile ()
    end if
    wend

    Thx
    FF.




    ------------------

  • #2
    Although I've not done much with mailslots, it seems plausable to use a separate thread to do the monitoring of the mailslot.

    This thread can make use of the SetMailslotInfo() API, with the %MAILSLOT_WAIT_FOREVER flag.

    Of course, you could just continuously poll the GetMailslotInfo() function with a specific timeout, but that will use CPU time servicing the loop. Using the "wait forever" option would be a much cleaner approach.

    For examples with Mailslots, I suggest you take a trip to www.msdn.microsoft.com


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Indeed, I was also thinking about adding a second thread. I haven't worked with them yet, though. I ordered a couple of books on Windows network programming.

      Thx!
      FF.

      ------------------

      Comment

      Working...
      X