Click here to Skip to main content
15,909,829 members
Home / Discussions / C#
   

C#

 
GeneralRe: Get the process-name that locked the file Pin
J4amieC5-Mar-10 4:16
J4amieC5-Mar-10 4:16 
GeneralRe: Get the process-name that locked the file Pin
Björn T.J.M. Spruit5-Mar-10 5:09
Björn T.J.M. Spruit5-Mar-10 5:09 
GeneralRe: Get the process-name that locked the file Pin
Dave Kreskowiak5-Mar-10 7:49
mveDave Kreskowiak5-Mar-10 7:49 
GeneralDon't you just hate it Pin
Ennis Ray Lynch, Jr.5-Mar-10 5:34
Ennis Ray Lynch, Jr.5-Mar-10 5:34 
GeneralRe: Don't you just hate it Pin
J4amieC5-Mar-10 6:03
J4amieC5-Mar-10 6:03 
GeneralThe difference Pin
Ennis Ray Lynch, Jr.5-Mar-10 6:17
Ennis Ray Lynch, Jr.5-Mar-10 6:17 
GeneralRe: The difference Pin
Björn T.J.M. Spruit5-Mar-10 10:35
Björn T.J.M. Spruit5-Mar-10 10:35 
QuestionRequest.BeginGetResponse probem in Windows 7 and unexpected Blocking behaviour Pin
vivasaayi4-Mar-10 23:45
vivasaayi4-Mar-10 23:45 
Hello Readers,

I am downloading a Html File using the following method.

<pre>public void LoadInitialData()
{
HttpWebRequest request = null;

try
{
Stopwatch sw = new Stopwatch();

RaiseStateChangedEvent(10, "Creating Connection to Server");

request = (HttpWebRequest)(WebRequest.Create(this._ServerUrl));

RaiseStateChangedEvent(20, "Connected to Server");

int timeout = request.Timeout;

if (request != null)
{
try
{
sw.Start();
request.BeginGetResponse(HttpRequestCallBackMethod, request);
sw.Stop();

RaiseStateChangedEvent(40, "Waiting for Data from Server --Time Taken: " + sw.ElapsedMilliseconds);
}
catch (Exception ex)
{
if (onErrorOccured != null)
onErrorOccured(ex.Message + "\n" + ex.StackTrace);
}
}
}

catch (Exception ex)
{
if (onErrorOccured != null)
onErrorOccured(ex.Message + "\n" + ex.StackTrace);
}
}

private void HttpRequestCallBackMethod(IAsyncResult iar)
{
RaiseStateChangedEvent(70, "Data Received From Server");


HttpWebRequest myHttpWebRequest = iar.AsyncState as HttpWebRequest;
HttpWebResponse response = (HttpWebResponse)myHttpWebRequest.EndGetResponse(iar);

using (StreamReader input = new StreamReader(response.GetResponseStream()))
{
string data = input.ReadToEnd();
RaiseStateChangedEvent(80, "Processing received Data");
ProcessData(data);
RaiseStateChangedEvent(100, "Completed Loading Initial Data");
}
}

private void RaiseStateChangedEvent(int progress, string message)
{
if (onStateChanged != null)
onStateChanged.Invoke(progress, message);
}

private void ProcessData(string data)
{
Console.WriteLine("Download Completed - Do any Processing here");
}</pre>

The program is written in .Net 2.0. When I try to run the same in Windows 7, I am not successful.

In Win7, Whenever I am calling this method continously (ie, 10 times in a for loop), I am not getting the replies for all the requests (the callback is not executed all time, only 5 or 6 responses I am getting). In 2000, Xp, Vista the program runs with no problem.

I have added a stopwatch to mesure the time it takes to invoke request.BeginGetResponse method. And the initial request is blocking the while application for 3 seconds (usually it should not. By calling teh LoadInitialData method in a seperate thread I managed the application from blocking).

Can anybody give some suggestions about this problem?

Thanks in advance.
AnswerRe: Request.BeginGetResponse probem in Windows 7 and unexpected Blocking behaviour (Fixed) Pin
vivasaayi5-Mar-10 0:28
vivasaayi5-Mar-10 0:28 
QuestionProblem while converting class object to string using XmlSerializer Pin
nagendrathecoder4-Mar-10 23:30
nagendrathecoder4-Mar-10 23:30 
AnswerMessage Closed Pin
5-Mar-10 1:33
stancrm5-Mar-10 1:33 
GeneralRe: Problem while converting class object to string using XmlSerializer Pin
nagendrathecoder5-Mar-10 1:41
nagendrathecoder5-Mar-10 1:41 
GeneralMessage Closed Pin
5-Mar-10 3:48
stancrm5-Mar-10 3:48 
GeneralRe: Problem while converting class object to string using XmlSerializer Pin
nagendrathecoder5-Mar-10 18:50
nagendrathecoder5-Mar-10 18:50 
GeneralRe: Problem while converting class object to string using XmlSerializer Pin
nagendrathecoder5-Mar-10 2:05
nagendrathecoder5-Mar-10 2:05 
QuestionGet correct case of Filename Pin
DanielWehrle4-Mar-10 20:33
DanielWehrle4-Mar-10 20:33 
AnswerMessage Closed Pin
4-Mar-10 20:38
stancrm4-Mar-10 20:38 
GeneralRe: Get correct case of Filename Pin
DanielWehrle5-Mar-10 4:05
DanielWehrle5-Mar-10 4:05 
AnswerRe: Get correct case of Filename Pin
Calla4-Mar-10 21:29
Calla4-Mar-10 21:29 
GeneralRe: Get correct case of Filename Pin
David Skelly5-Mar-10 1:41
David Skelly5-Mar-10 1:41 
GeneralRe: Get correct case of Filename Pin
AspDotNetDev5-Mar-10 2:08
protectorAspDotNetDev5-Mar-10 2:08 
GeneralRe: Get correct case of Filename Pin
David Skelly5-Mar-10 5:51
David Skelly5-Mar-10 5:51 
GeneralRe: Get correct case of Filename Pin
Dave Kreskowiak5-Mar-10 7:53
mveDave Kreskowiak5-Mar-10 7:53 
GeneralRe: Get correct case of Filename Pin
Luc Pattyn5-Mar-10 1:42
sitebuilderLuc Pattyn5-Mar-10 1:42 
GeneralRe: Get correct case of Filename Pin
AspDotNetDev5-Mar-10 2:12
protectorAspDotNetDev5-Mar-10 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.