473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Making form active when reading from tcpClient

I'm having a problem with the following excerpt:

dim tcpCli As New TcpClient

Dim ns As NetworkStream = tcpCli.GetStream

Dim sw As New StreamWriter(ns, System.Text.Encoding.Default)

Dim sr As New StreamReader(ns)

Dim result As String

result = sr.ReadLine

The problem is that the whole form hangs when on the last line, waiting for
an input. I want to have a button so that when waiting for an input, the
user can abort. I've tried threading to no avail. I've also tried
Application.DoEvents() before the read line.

Any ideas?

- Jerry
Nov 21 '05 #1
2 1353
Hi,

Use a seperate thread to prevent the app from locking up while
reading the line of data.

http://msdn.microsoft.com/msdnmag/is...s/default.aspx
Ken
-----------------
"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:41**********************@ptn-nntp-reader02.plus.net...
I'm having a problem with the following excerpt:

dim tcpCli As New TcpClient

Dim ns As NetworkStream = tcpCli.GetStream

Dim sw As New StreamWriter(ns, System.Text.Encoding.Default)

Dim sr As New StreamReader(ns)

Dim result As String

result = sr.ReadLine

The problem is that the whole form hangs when on the last line, waiting for
an input. I want to have a button so that when waiting for an input, the
user can abort. I've tried threading to no avail. I've also tried
Application.DoEvents() before the read line.

Any ideas?

- Jerry

Nov 21 '05 #2
Thank you for that.

It sort of works, but suddenly I have stopped being able to reference any of
the control properties on my form from within the asynch thread. For example
a textbox will have some text in it, but when I try and read it, it reports
"Nothing" and when I set a button visible, it doesn't have any effect - but
it doesn't object so abviously it is seeing the control OK. The strange
thing is that is was working OK, and it's now stopped and I can't fathom out
what I have done. Everything works from the main thread OK.

- Jerry

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:e4*************@TK2MSFTNGP14.phx.gbl...
Hi,

Use a seperate thread to prevent the app from locking up while
reading the line of data.

http://msdn.microsoft.com/msdnmag/is...s/default.aspx
Ken
-----------------
"Jerry Spence1" <je**********@somewhere.com> wrote in message
news:41**********************@ptn-nntp-reader02.plus.net...
I'm having a problem with the following excerpt:

dim tcpCli As New TcpClient

Dim ns As NetworkStream = tcpCli.GetStream

Dim sw As New StreamWriter(ns, System.Text.Encoding.Default)

Dim sr As New StreamReader(ns)

Dim result As String

result = sr.ReadLine

The problem is that the whole form hangs when on the last line, waiting for an input. I want to have a button so that when waiting for an input, the
user can abort. I've tried threading to no avail. I've also tried
Application.DoEvents() before the read line.

Any ideas?

- Jerry

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Richy | last post by:
Hi, I'm using a winsock active-x component in a C# program. I can send data using the following: byte buffer = new byte; axWinsock1.SendData( buffer); But to receive isn't as easy.
5
by: Stephen Lamb | last post by:
I have a background worker thread which I start from a form's HandleCreated event that makes calls back to the form using Invoke. During shutdown the form is disposed and the background worker...
7
by: Roemer | last post by:
Hi all I stumbled over a new problem: I have a programm with just a class that is asynchronous listening for network connections. As soon as someone connected, a new form needs to be created....
0
by: Al Wilkerson | last post by:
Hey, Has anyone ever got a "Unable to read data from transport connected" message after reading data from a streamreader composed of a networkstream. For example: Server TcpListener...
2
by: Christopher Brandsdal | last post by:
Hi! I have found a script to lookup domain names, but it is written in C#. I want so bad to translate this to VB! Can anyone help me? I have tried myself. The script seems to run fine, but I...
0
by: tshad | last post by:
I can't seem to retrieve messages that are not in my mailbox from Exchange. If I am reading mail from my Exchange server, I will get messages that are in my inbox that have already been read but...
13
by: active | last post by:
With VS2005 the windows form designer uses the files *.Designer.vb I hope no one at MS is reading this because I know it will upset them to know - I like the old way better! I've been looking...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
1
by: =?Utf-8?B?RGFydGgtQ3ot?= | last post by:
Hi, I'm beginner in Visual C++ so I want to ask you a question. And I'm not good in English:D So I have the program which communicates over sockets. The program has to connect to the server and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.