using this.invoke in wm2003
hi ,
i am working in WM2003 . in that i am not finding any option to stop the thread . in my case , the issue is as follows:
1. i am showing some animation in main thread .
2. i am fetching the information from network in another thread .
3. at the same time i am having a softkey ,when i press that softkey the network fetching should be stopped and return to the main menu.
but its not happening so .
my code is as follows :
public delegate byte[] httpRequest();
public event httpRequest ht ;
puzzlefetching = new Thread(new ThreadStart(docancel));
puzzlefetching.Start();
public void docancel()
{
httpRequest ht = null;
ht += new httpRequest(dorequestHttp);
byte[] data = null;
try
{
data = (byte[])this.Invoke(ht);
}
catch (WebException w)
{
}
}
public byte[] dorequestHttp()
{
String url = uRl;
byte[] dat = null;
Uri uri = new Uri(url);
request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
int length = (int)response.ContentLength;
dat = new byte[length];
dataStream.Read(dat, 0, length);
reader.Close();
dataStream.Close();
response.Close();
}
but the above code is showing arguement exception during runtime
At the same time i am running a animation in main thread using forms timer
|