471,319 Members | 1,633 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

WebClient question

I have a connection through WebClient running via a thread. Then I call
a .OpenRead(). I would like the main thread to be able to cancel this
connection. How do I go about it.

Dec 13 '05 #1
1 1241
Your main thread should not cancel the connection. Rather, you should
set a flag somewhere that is checked through each iteration of your routine
which reads from the stream. If the flag is set, then you break out of the
loop.

You should also use the Stream returned from OpenRead in a using
statement, so that you get auto-dispose semantics.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ch***************@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I have a connection through WebClient running via a thread. Then I call
a .OpenRead(). I would like the main thread to be able to cancel this
connection. How do I go about it.

Dec 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Seymen Ertas | last post: by
reply views Thread by belfast neil | last post: by
reply views Thread by Saverio Tedeschi | last post: by
1 post views Thread by Deepson Thomas | last post: by
1 post views Thread by Chris Dunaway | last post: by
3 posts views Thread by Chip | last post: by
1 post views Thread by Frank Rizzo | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.