Click here to Skip to main content
15,905,679 members
Home / Discussions / C#
   

C#

 
AnswerCreate one yourself. This is very easy. [modified] Pin
John M. Drescher18-Sep-08 2:52
John M. Drescher18-Sep-08 2:52 
Questionquery Pin
lankaudaranga17-Sep-08 20:44
lankaudaranga17-Sep-08 20:44 
AnswerRe: query Pin
Blue_Boy17-Sep-08 21:58
Blue_Boy17-Sep-08 21:58 
AnswerRe: query Pin
Mycroft Holmes17-Sep-08 22:03
professionalMycroft Holmes17-Sep-08 22:03 
AnswerRe: query Pin
Harvey Saayman18-Sep-08 2:47
Harvey Saayman18-Sep-08 2:47 
QuestionHot Mail Contacts Pin
nhss17-Sep-08 20:32
nhss17-Sep-08 20:32 
AnswerRe: Hot Mail Contacts Pin
Mycroft Holmes17-Sep-08 22:20
professionalMycroft Holmes17-Sep-08 22:20 
QuestionTcpClient connects very slow [modified] Pin
Mark Snow17-Sep-08 20:20
Mark Snow17-Sep-08 20:20 
hi i am trying to write a method for checking which hosts are alive by connecting to the known application port. but i ran into a very weird thing, connecting to 200 hosts takes me about 10 minutes in my application and not more then 45 sec on a test application with same piece of code.
this are windows applications, the code runs in a separate thread and it's logic is:

int threads = 200;
List<system.net.sockets.tcpclient> clientList = new List<system.net.sockets.tcpclient>(threads);
List<iasyncresult> resultList = new List<iasyncresult>();

for (int i = 0; i < threads; i++)
{
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
IAsyncResult result = null;
try
{
	result = client.BeginConnect(testedHost, testedPort, null, null);
}
catch
{
}
clientList.Add(client);
resultList.Add(result);
}

for (int i = 0; i < threads; i++)
{
try
{
	clientList[i].EndConnect(resultList[i]);
	clientList[i].Close();
}
catch
{
	//processint the result and determining if tested host is alive or not
}

}
</iasyncresult></iasyncresult></system.net.sockets.tcpclient></system.net.sockets.tcpclient>


did anyone have problems with BeginConnect/EndConnect, or has any clue why the same block of code could work much slower? in both applications only the main thread and additional thread(where this code runs) are present, no more threads to take the cpu resources.

modified on Thursday, September 18, 2008 2:28 AM

AnswerRe: TcpClient connects very slow Pin
leppie17-Sep-08 22:25
leppie17-Sep-08 22:25 
GeneralRe: TcpClient connects very slow Pin
Mark Snow17-Sep-08 22:38
Mark Snow17-Sep-08 22:38 
GeneralRe: TcpClient connects very slow Pin
leppie17-Sep-08 22:49
leppie17-Sep-08 22:49 
GeneralRe: TcpClient connects very slow Pin
Mark Snow17-Sep-08 23:12
Mark Snow17-Sep-08 23:12 
GeneralRe: TcpClient connects very slow Pin
leppie17-Sep-08 23:49
leppie17-Sep-08 23:49 
QuestionAlpha numeric sorting for dataview/datatable Pin
avtar11117-Sep-08 19:27
avtar11117-Sep-08 19:27 
AnswerRe: Alpha numeric sorting for dataview/datatable Pin
Mycroft Holmes17-Sep-08 22:25
professionalMycroft Holmes17-Sep-08 22:25 
QuestionHow to use adapter when returned by the following function Pin
CPK_201117-Sep-08 19:00
CPK_201117-Sep-08 19:00 
AnswerRe: How to use adapter when returned by the following function Pin
N a v a n e e t h17-Sep-08 20:33
N a v a n e e t h17-Sep-08 20:33 
QuestionWindows Form allows click events on disable buttons ? Pin
nvngyl17-Sep-08 18:57
nvngyl17-Sep-08 18:57 
AnswerRe: Windows Form allows click events on disable buttons ? Pin
Steve Echols17-Sep-08 19:29
Steve Echols17-Sep-08 19:29 
GeneralRe: Windows Form allows click events on disable buttons ? Pin
nvngyl17-Sep-08 19:55
nvngyl17-Sep-08 19:55 
AnswerRe: Windows Form allows click events on disable buttons ? Pin
N a v a n e e t h17-Sep-08 20:56
N a v a n e e t h17-Sep-08 20:56 
QuestionWin32 Shell Lightweight Utility API (shlwapi.dll) wrapper Pin
Paul Selormey17-Sep-08 18:48
Paul Selormey17-Sep-08 18:48 
AnswerRe: Win32 Shell Lightweight Utility API (shlwapi.dll) wrapper Pin
N a v a n e e t h17-Sep-08 20:58
N a v a n e e t h17-Sep-08 20:58 
GeneralRe: Win32 Shell Lightweight Utility API (shlwapi.dll) wrapper Pin
Paul Selormey17-Sep-08 21:33
Paul Selormey17-Sep-08 21:33 
QuestionNativeMethods is inaccesible due to its protection lavel Pin
amit_8317-Sep-08 18:44
amit_8317-Sep-08 18:44 

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.