How do you tell (programmatically) when the queue is empty?

Moderator: Project members

Post Reply
Message
Author
Perry2
550 File not found
Posts: 34
Joined: 2005-04-30 08:43

How do you tell (programmatically) when the queue is empty?

#1 Post by Perry2 » 2005-05-01 00:04

I was seeing the main dialog stay up because the queue list control still had items in it, so IsQueueEmpty was returning false.

I'm not sure why they were there, and I've not been able to reproduce it.

They might be errors?

Anyway, my real question is, when is it safe to close FileZilla programmatically because there are no more attempts to be made.

CQueueCtrl::TransferNextFile has pretty complicated logic that I don't want to have to imitate.

Also, CCommandQueue::OnRetryTimer has pretty complicated logic.

Eventually, will the list ctrl window empty, in which case, I can just wait for IsQueueEmpty to return true, or do I need some more complicated or other check?

User avatar
botg
Site Admin
Posts: 35562
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

#2 Post by botg » 2005-05-01 08:56

Wait until m_nProcessQueue is zero again.

Perry2
550 File not found
Posts: 34
Joined: 2005-04-30 08:43

#3 Post by Perry2 » 2005-05-01 19:25

So,

#1a)
First wait until IsQueueEmpty(), and then wait until nProcessQueue is 0

#1b)
Wait until both IsQueueEmpty() and nProcessQueue is 0 simultaneously

#2)
Wait until either IsQueueEmpty() or nProcessQueue is 0

#3)
Wait until nProcessQueue is 0 (ignore IsQueueEmpty)


Which one is best?

Thanks!

User avatar
botg
Site Admin
Posts: 35562
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

#4 Post by botg » 2005-05-01 19:51

If all transfers have completed, either successfully or have failed with too many errors, then IsQueueEmpty returns true and m_nProcessQueue will be 0.
If the user interrupts the transfer, m_nProcessQueue will be 0 as well, but depending how the transfer was stopped, IsQueueEmpty may or may not return true. If using the toolbar button for the queue, IsQueueEmpty would return false.[/code]

Perry2
550 File not found
Posts: 34
Joined: 2005-04-30 08:43

#5 Post by Perry2 » 2005-05-01 23:27

Does that mean #3 above?

User avatar
botg
Site Admin
Posts: 35562
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

#6 Post by botg » 2005-05-02 07:46

I would use #3

Perry2
550 File not found
Posts: 34
Joined: 2005-04-30 08:43

#7 Post by Perry2 » 2005-05-02 11:11

Great -- thank you!

PS: One nice thing about using FileZilla in a script, as I am with my patch, is that you can test the script by running it in the interactive desktop, and then you get to see the dialog popup and the files transfer with the pretty progress display.

:)

Post Reply