Alternative for Postmessage and sendmessage

后端 未结 5 1887
北荒
北荒 2021-01-31 00:46

i have a program which is using several threads to execute some task. Each thread is having a bunch of task to execute. after executing one of them, each thred will call a post

5条回答
  •  星月不相逢
    2021-01-31 00:50

    Instead of posting messages, you can put messages in a thread safe queue.

    In your main thread, use a timer event to drain the queue.

    To remain responsive though, do not stay in the timer event too long.

    In many cases I have found this better than posting messages.

    In Delphi XE there is a class called TThreadedQueue which you can use.

    Edit :

    I uploaded a sample sort application utilizing different thread to GUI techniques.

    See ThreadedQueueDemo

提交回复
热议问题