Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Morning friends,

I am currently developing an IP pinger and I want to create threads for each IP address, so I want to create 100 thread each thread takes an IP address until I complete the course of the example IP address: This is the code i 'm using

C#
string ip = "129168.";

             for (int i = 0; i <256; i + +)
             {
                 for (int j = 0 j <256; j + +)
                 {
                     string ip = newIP + i.ToString () + "." + J.ToString ();

                     ping(ip);//methode Ping

                     Application.DoEvents ();
                 }
             }


this idea is like the ip scanner, for each IP address it create a thread to excute a methode...I hope that's clear

thank you
Posted

Why don't you use a ThreadPool then. You can implement the logic in a different class and invoke with ThreadPool.QueueUserWorkItem method.

http://msdn.microsoft.com/en-us/library/system.threading.threadpool.queueuserworkitem%28v=vs.80%29.aspx[^]
 
Share this answer
 
Comments
carlos pin 27-Sep-11 4:46am    
Give me an exemple please for the TreadPool
Thank you
CodingLover 27-Sep-11 5:23am    
MSDN has a nice example.

http://msdn.microsoft.com/en-us/library/3dasc8as%28v=vs.80%29.aspx
Have a look at Simple Ping Utility with GUI[^].
 
Share this answer
 
Comments
carlos pin 27-Sep-11 4:47am    
It don't contain what i need see my question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900