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

C#

 
GeneralRe: Get back in the Soapbox Kyle! Pin
Pete O'Hanlon4-Mar-08 11:19
mvePete O'Hanlon4-Mar-08 11:19 
GeneralRe: ANYONE HELP HELP HELP HELP I NEED IT BEFORE MAR 6,2008 Pin
Anthony Mushrow4-Mar-08 13:07
professionalAnthony Mushrow4-Mar-08 13:07 
GeneralRe: ANYONE HELP HELP HELP HELP I NEED IT BEFORE MAR 6,2008 Pin
Guffa4-Mar-08 23:39
Guffa4-Mar-08 23:39 
GeneralRe: ANYONE HELP HELP HELP HELP I NEED IT BEFORE MAR 6,2008 Pin
Ravi Bhavnani5-Mar-08 4:35
professionalRavi Bhavnani5-Mar-08 4:35 
GeneralDataset disabling and reenabling constraints Pin
~~~Johnny~~~4-Mar-08 9:47
~~~Johnny~~~4-Mar-08 9:47 
GeneralUsing option (switches) with Process.Start Pin
TheJudeDude4-Mar-08 9:43
TheJudeDude4-Mar-08 9:43 
GeneralRe: Using option (switches) with Process.Start Pin
Giorgi Dalakishvili4-Mar-08 10:02
mentorGiorgi Dalakishvili4-Mar-08 10:02 
QuestionSockets and Threads Pin
Echilon4-Mar-08 8:04
Echilon4-Mar-08 8:04 
I'm working on an FTP client, and using sockets to receive data from a server. When the server sends any data back to the application, I have to wait before the application repsonds. I'd like to starts the transfer for the data in a new thread if possible, leaving the rest of the app free to respond to the user and not just show an hourglass. Is this possible? I'm unsure how to get the data back from the thread.
<br />
			Socket socket = openSocket();<br />
			SendCommand("MLSD");<br />
			if(statusCode != 125 && statusCode != 150) {<br />
				LogText = "Error opening connection\n";<br />
				return;<br />
			}<br />
			DateTime timeOutDate = DateTime.Now.AddSeconds(timeOut);<br />
			bldBuffer.Remove(0, bldBuffer.Length);<br />
			while(DateTime.Now < timeOutDate) {<br />
				int bytes = socket.Receive(buffer, buffer.Length, 0);<br />
				bldBuffer.Append(Encoding.ASCII.GetString(buffer, 0, bytes));<br />
				if(bytes < buffer.Length) {<br />
					// there weren't enough bytes to fill the buffer, so the stream is finished<br />
					break;<br />
				}<br />
			}<br />
			socket.Close();<br />

OpenSocket() creates a new socket to the server, and SendCommand() send the specified command over the control connection. The application works, it's just that I have to wait for it to respond.

Thanks for any input.
GeneralRe: Sockets and Threads Pin
led mike4-Mar-08 8:34
led mike4-Mar-08 8:34 
GeneralPerformance Explorer Pin
netJP12L4-Mar-08 8:03
netJP12L4-Mar-08 8:03 
GeneralRe: Performance Explorer Pin
led mike4-Mar-08 8:18
led mike4-Mar-08 8:18 
GeneralRe: Performance Explorer Pin
Pete O'Hanlon4-Mar-08 10:55
mvePete O'Hanlon4-Mar-08 10:55 
GeneralRe: Performance Explorer Pin
led mike4-Mar-08 11:07
led mike4-Mar-08 11:07 
GeneralRe: Performance Explorer Pin
Pete O'Hanlon4-Mar-08 11:11
mvePete O'Hanlon4-Mar-08 11:11 
GeneralRe: Performance Explorer Pin
Luc Pattyn4-Mar-08 13:02
sitebuilderLuc Pattyn4-Mar-08 13:02 
GeneralFile Upload Question Pin
Derrick.greer4-Mar-08 7:47
Derrick.greer4-Mar-08 7:47 
GeneralRe: File Upload Question Pin
led mike4-Mar-08 8:16
led mike4-Mar-08 8:16 
GeneralRe: File Upload Question Pin
Derrick.greer4-Mar-08 8:30
Derrick.greer4-Mar-08 8:30 
GeneralRe: File Upload Question Pin
led mike4-Mar-08 8:43
led mike4-Mar-08 8:43 
GeneralRe: File Upload Question Pin
Derrick.greer4-Mar-08 9:03
Derrick.greer4-Mar-08 9:03 
GeneralRe: File Upload Question Pin
led mike4-Mar-08 9:11
led mike4-Mar-08 9:11 
GeneralRe: File Upload Question Pin
Pete O'Hanlon4-Mar-08 10:14
mvePete O'Hanlon4-Mar-08 10:14 
GeneralRe: File Upload Question Pin
DaveyM694-Mar-08 9:20
professionalDaveyM694-Mar-08 9:20 
GeneralListView confusion Pin
Richard Blythe4-Mar-08 7:18
Richard Blythe4-Mar-08 7:18 
GeneralRe: ListView confusion Pin
led mike4-Mar-08 8:13
led mike4-Mar-08 8:13 

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.