0 votes
by (120 points)
edited

I'm trying to abort a Pop3 GetMailMessage operation but it just doesn't seem to work. I have the GetMailMessage running on a separate thread and from the application thread, i tried pop.Abort() when I click on a button and I see the message is downloading (I have a progress bar for that). The message keeps on downloading.

I also tried adding pop.Abort() in a function that handles the TransferProgress event. It does not work! Any advice?

    pop.TransferProgress += PopTransferProgress;

    private void PopTransferProgress(object sender, Pop3TransferProgressEventArgs e)
    {
            pop.Abort();
    }
Applies to: Rebex Secure Mail

1 Answer

0 votes
by (147k points)
edited

The Abort method doesn't abort the operation immediately, but only if it doesn't finish within the time interval specified by Pop3 object's AbortTimeout method (which is 3000 by default - 3 seconds). Unfortunately, this information is missing from Abort method's documentation.

If you wish to abort an operation immediately, simply call Pop3 object's Dispose method. The Pop3 instance won't be usable any more after this, but that would be the case for Abort method as well if the time specified by AbortTimeout actually elapsed. (Reason: The POP3 protocol doesn't support aborting message retrieval.)

by (120 points)
I have tried setting the AbortTimeout to 1000ms (which I understand is the minimum), but that didn't work either. Will try the Dispose method. Thank you.
by (120 points)
That did it, thank you again.
by (147k points)
Further investigation revealed that you are right - there is a bug in the Pop3 object that causes the abort process not to work correctly because the flag set by Abort method is only checked when no data is available to be received. This will be fixed in the next release. Many thanks for bringing this to our attention!
...