Aug 15th, 2010 by carrumba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| using System;
using System.Threading;
namespace Threading
{
public class Program
{
protected static void threadFunction()
{
Console.WriteLine("Inside the thread. ");
while (true)
{
Console.Write("." );
Thread.Sleep(400);
}
}
static void Main(string[] args)
{
Thread lThread = new Thread(new ThreadStart(threadFunction));
lThread.Start();
Thread.Sleep(5000);
lThread.Abort();
lThread.Join();
}
}
} |
tags: C#, Thread
Posted in C#, Coders corner | comments off
Aug 15th, 2010 by carrumba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| using System;
using System.Threading;
namespace Threading
{
public class Program
{
static bool mStopThread = false;
protected static void threadFunction()
{
Console.WriteLine("Inside the thread. ");
while (mStopThread == false)
{
Console.Write("." );
Thread.Sleep(400);
}
}
static void Main(string[] args)
{
Thread lThread = new Thread(new ThreadStart(threadFunction));
lThread.Start();
Thread.Sleep(5000);
mStopThread = true;
lThread.Join();
}
}
} |
tags: C#, Thread
Posted in C#, Coders corner | comments off
Aug 14th, 2010 by carrumba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| using System;
using System.Threading;
namespace Threading
{
public class Program
{
protected static void threadFunction()
{
int lCounter;
for (lCounter = 0; lCounter < 10; lCounter++)
{
Console.WriteLine(lCounter);
Thread.Sleep(400);
}
}
static void Main(string[] args)
{
Thread lThread = new Thread(new ThreadStart(threadFunction));
lThread.Start();
lThread.Join();
}
}
} |
Posted in C#, Coders corner | comments off
Aug 14th, 2010 by carrumba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
namespace HostName
{
public class Program
{
static void Main(string[] args)
{
String lComputerName = Dns.GetHostName();
IPAddress[] localIPs = Dns.GetHostAddresses(lComputerName);
if (localIPs.Length > 0)
foreach (IPAddress lAddress in localIPs)
Console.WriteLine(lAddress);
}
}
} |
Posted in C#, Coders corner | comments off
Aug 14th, 2010 by carrumba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
namespace HostName
{
public class Program
{
static void Main(string[] args)
{
string lHostName = Dns.GetHostName();
Console.WriteLine("Host name : " + lHostName);
}
}
} |
Posted in C#, Coders corner | comments off
Aug 13th, 2010 by carrumba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
using System;
using System.Text;
using System.Net;
namespace HostName2IP
{
class Program
{
static void Main(string[] args)
{
IPHostEntry lHost = Dns.GetHostByName("www.google.com");
IPAddress lIPAddr = lHost.AddressList[0];
Console.WriteLine(lIPAddr);
}
}
} |
Posted in C#, Coders corner | no comments »