WebClient.DownloadFile freezes when the computer is locked

I have a console application that includes (new WebClient()).DownloadFile(source,target) (short for short).

I am running on a Windows 2003 server, on top of rdp.

When the server is blocked (it is blocked after several minutes of non-use), the program simply stops working, it just crashes or something else, it just does not progress.

 Console.WriteLine("Downloading to {0} ...", localTempFile); sw.Start(); Client.DownloadFile(url + "/" + fileName, localTempFile); sw.Stop(); Console.WriteLine("{0} | Done in {1}s",DateTime.Now,sw.ElapsedMilliseconds / 1000); 

I really don’t know where to start with this problem, there’s nothing complicated, it’s just a simple linear console application. Any ideas?

+4
source share
1 answer

First, you need to install if this happens not only with WebClient.DownloadFile , but also with other programs, do this by writing a quick program that may print time.

The next thing that will be is your code displaying the active Window anyway that could stop it? When the computer is locked, there is no active window.

Another scenario could be one of your services that shuts down when the computer is locked, causing WebClient to stop processing, possibly a network policy or something else.

Hope this helps.

+1
source

Source: https://habr.com/ru/post/1338101/


All Articles