подскажите такая вещь есть процедура
public void TestDownlads()
{
countTheared = 0;
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
for (int i = 0; i < 10; i++)
{
DownloadProcess proce = new DownloadProcess();
proce.OnFinishDownload += new FinishDownloadDelegate(proce_OnFinishDownload);
proce.StartByte = countTheared;
countTheared += 1024;
proce.EndByte = countTheared;
proce.OnException += new ExceptionDelegate(proce_OnException);
proce.StartTest();
}
}
void proce_OnException(long Messeng, long Source, long StackTrace, bool Tail)
{
DownloadProcess proce = new DownloadProcess();
proce.OnFinishDownload += new FinishDownloadDelegate(proce_OnFinishDownload);
proce.StartByte = Messeng;
proce.EndByte = Source;
proce.OnException += new ExceptionDelegate(proce_OnException);
proce.StartTest();
}
int countTheared = 0;
void proce_OnFinishDownload(long parametrs, bool Tail, long lDownloads)
{
countTheared++;
long testmb = (1024*1024)*1000;
if (countTheared < testmb)
{
DownloadProcess proce = new DownloadProcess();
proce.OnFinishDownload += new FinishDownloadDelegate(proce_OnFinishDownload);
proce.StartByte = countTheared;
countTheared += 1024;
proce.EndByte = countTheared;
proce.OnException += new ExceptionDelegate(proce_OnException);
proce.StartTest();
summ = countTheared/1024;
}
else
{
MessageBox.Show("Test Finish");
}
}
И сама процедура потока
public void StartTest()
{
m_Terminated = false;
FinishDownloadThread = false;
CloseDW = false;
if (downloader != null)
{
if (downloader.ThreadState == ThreadState.Stopped)
{
m_EvSuspend = new ManualResetEvent(true);
downloader = new Thread(new ThreadStart(downloadTest));
downloader.IsBackground = true;
downloader.Start();
}
}
else
{
m_EvSuspend = new ManualResetEvent(true);
downloader = new Thread(new ThreadStart(downloadTest));
downloader.IsBackground = true;
downloader.Start();
}
}
void downloadTest()
{
HttpWebResponse webResponse = null;
HttpWebRequest webRequest = null;
Stream strResponse = null;
try
{
Type _TypeHttpWebRequest = typeof(HttpWebRequest);
object[] args = new object[3];
Random r = new Random();
webRequest = (HttpWebRequest)WebRequest.Create("http://www.bl/wmv/vid.wmv");
args[0] = "bytes";
int MethodI;
args[1] = StartByte.ToString();
long total = EndByte - 1;
args[2] = total.ToString();
MethodInfo[] _method = _TypeHttpWebRequest.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic);
for (MethodI = 0; MethodI < _method.Length; MethodI++)
{
if (_method[MethodI].Name == "AddRange") break;
}
_method[MethodI].Invoke(webRequest, args);
webRequest.Credentials = CredentialCache.DefaultCredentials;
//webRequest.Timeout = 10000;
webResponse = (HttpWebResponse)webRequest.GetResponse();
strResponse = webResponse.GetResponseStream();
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, new FinishDownloadDelegate(this.OnFinishDownload), 1024, new object[] { true, 10 });
}
catch
{
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, new ExceptionDelegate(this.OnException), StartByte, new object[] { EndByte, 0, true });
}
finally
{
if (m_EvSuspend != null)
{
m_EvSuspend.Close();
}
if (webRequest != null)
{
webRequest.Abort();
}
if (webResponse != null)
{
webRequest.Abort();
}
if (strResponse != null)
{
strResponse.Close();
}
}
}
Проблема в том что после того как прокачала около 10 000 kb программа перестает качать и винда ложится т.е. выключается на мышке правая кнопка, горячие клавиши ...
Подскажите как можно выйти из ситуации ?