diff options
Diffstat (limited to 'Plugins/utils/ContactAsyncQueue.cpp')
-rw-r--r-- | Plugins/utils/ContactAsyncQueue.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Plugins/utils/ContactAsyncQueue.cpp b/Plugins/utils/ContactAsyncQueue.cpp index 7be4cfe..ca6bf83 100644 --- a/Plugins/utils/ContactAsyncQueue.cpp +++ b/Plugins/utils/ContactAsyncQueue.cpp @@ -48,12 +48,11 @@ ContactAsyncQueue::ContactAsyncQueue(pfContactAsyncQueueCallback fContactAsyncQu ContactAsyncQueue::~ContactAsyncQueue()
{
- if (finished == 0)
- finished = 1;
- SetEvent(hEvent);
+ Finish();
+
int count = 0;
while(finished != 2 && ++count < 50)
- Sleep(10);
+ Sleep(30);
for (int i = 0; i < queue.getCount(); i++)
if (queue[i] != NULL)
@@ -62,6 +61,13 @@ ContactAsyncQueue::~ContactAsyncQueue() DeleteCriticalSection(&cs);
}
+void ContactAsyncQueue::Finish()
+{
+ if (finished == 0)
+ finished = 1;
+ SetEvent(hEvent);
+}
+
void ContactAsyncQueue::Lock()
{
EnterCriticalSection(&cs);
@@ -170,6 +176,9 @@ void ContactAsyncQueue::Thread() {
ResetEvent(hEvent);
+ if (finished)
+ break;
+
Lock();
if (queue.getCount() <= 0)
|