Is there any better way to avoid this Exception?

Emon Haque 3,176 Reputation points
2021-06-16T12:07:33.88+00:00

Here's what it does:

106199-test.gif

So when it takes fair amount of time in between BusyWindow.Activate and BusyWindow.Terminate, I don't get that exception, printing PDF or actual page for example, BUT when it takes less time I get that! How to avoid that without sleeping for some time?

EDIT
----
The Azure blocking issue, I mentioned earlier, is with dot Sleep after Thread. Updated the project in GitHub and put a sleep immediately after thread.Start() in Activate function of BusyWindow.cs, remove that to get into the issue.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,760 questions
0 comments No comments
{count} votes

Accepted answer
  1. DaisyTian-1203 11,621 Reputation points
    2021-06-17T08:44:43.267+00:00

    The two operations affect each other, probably because window is a global variable. Please add window = null; before the var thread = new Thread... in Activate. I tested with this added and it works well.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.