Click here to Skip to main content
15,904,828 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# method to restart the application Pin
Peace ON3-Feb-11 20:20
Peace ON3-Feb-11 20:20 
GeneralRe: C# method to restart the application Pin
ayandelhi3-Feb-11 20:30
ayandelhi3-Feb-11 20:30 
AnswerRe: C# method to restart the application Pin
Luc Pattyn3-Feb-11 21:53
sitebuilderLuc Pattyn3-Feb-11 21:53 
GeneralRe: C# method to restart the application Pin
ayandelhi3-Feb-11 23:32
ayandelhi3-Feb-11 23:32 
GeneralRe: C# method to restart the application Pin
Pete O'Hanlon4-Feb-11 1:48
mvePete O'Hanlon4-Feb-11 1:48 
GeneralRe: C# method to restart the application Pin
ayandelhi5-Feb-11 16:51
ayandelhi5-Feb-11 16:51 
QuestionGet GetKeyboardLayout for Active Window In Keyboard Hook Pin
Anubhava Dimri3-Feb-11 18:12
Anubhava Dimri3-Feb-11 18:12 
QuestionMulti Threading Pin
mj_developer3-Feb-11 13:35
mj_developer3-Feb-11 13:35 
Please pay attention to the following code:
Note: Thread t;

private void Form1_Load(object sender, EventArgs e)<br />
	{<br />
		t = new Thread(new ThreadStart(main));<br />
		t.Start();<br />
<br />
		Thread.Sleep(1000);<br />
<br />
		t = new Thread(new ThreadStart(main));<br />
		t.Start();<br />
	}<br />
		<br />
public void main()<br />
	{<br />
		int x, y, a, b;<br />
		double selectY;<br />
		Random rnd = new Random();<br />
		<br />
		x = rnd.Next(0, lblEnvironment.Width - 20);<br />
<br />
		Thread.Sleep(100);<br />
		y = rnd.Next(0, lblEnvironment.Height - 20);<br />
<br />
		if ((x > -20) && (x < lblEnvironment.Width))<br />
		{<br />
			Thread.Sleep(100);<br />
			selectY = rnd.NextDouble();<br />
<br />
			if (selectY < 0.5)<br />
				y = -20;<br />
			else<br />
				y = lblEnvironment.Height;<br />
		}<br />
		<br />
		a = rnd.Next(-5, 5);<br />
		Thread.Sleep(100);<br />
		b = rnd.Next(-5, 5);<br />
<br />
		while (a == 0) a = rnd.Next(-5, 5);<br />
		while (b == 0) b = rnd.Next(-5, 5);<br />
		<br />
		Pen pen = new Pen(Color.Red, 10);<br />
		Graphics g = lblEnvironment.CreateGraphics();<br />
		<br />
		while (true)<br />
		{<br />
			if (cancelThread)<br />
			{<br />
				cancelThread = false;<br />
				t.Abort();<br />
			}<br />
<br />
			g.DrawEllipse(pen, x, y, 20, 20);<br />
			<br />
			Thread.Sleep(100);<br />
			g.Clear(Color.White);<br />
<br />
			if (((x < 0) && (a < 0)) || ((x == lblEnvironment.Width) && (a > 0)))<br />
				a *= -1;<br />
			x += a;<br />
<br />
			if (((y < 0) && (b < 0)) || ((y == lblEnvironment.Height) && (b > 0)))<br />
				b *= -1;<br />
			y += b;<br />
<br />
			if ((x > lblEnvironment.Width - 25) || (x < 5))<br />
			{<br />
				t = new Thread(new ThreadStart(main));<br />
				t.Start();<br />
				<br />
				Thread.CurrentThread.Abort();<br />
			}<br />
<br />
			if ((y > lblEnvironment.Height - 25 && b > 0) || (y < 5 && b < 0))<br />
			{<br />
				b *= -1;<br />
			}<br />
		}<br />
	}



The scenario is as bellow:

At the beginning of the program two balls are appeared as 'Thread' and they start to move in various directions. If each one of them hit to the left or right wall then that ball must disappear and a new ball as 'Thread' must enter and this routine should be continued to the end. Currently everything is correct but the problem is that it seems both of balls use one resource (variables) and because of this are displayed blinking. What should I do to solve the problem?

Thank you
AnswerRe: Multi Threading Pin
Luc Pattyn3-Feb-11 14:02
sitebuilderLuc Pattyn3-Feb-11 14:02 
AnswerRe: Multi Threading Pin
_Maxxx_3-Feb-11 18:47
professional_Maxxx_3-Feb-11 18:47 
QuestionDLL Registration Issue Pin
turc16563-Feb-11 6:57
turc16563-Feb-11 6:57 
AnswerRe: DLL Registration Issue Pin
jim lahey3-Feb-11 8:46
jim lahey3-Feb-11 8:46 
GeneralRe: DLL Registration Issue Pin
turc16563-Feb-11 10:00
turc16563-Feb-11 10:00 
QuestionHow can i send io stream to specific USB Pin
Yanshof3-Feb-11 0:52
Yanshof3-Feb-11 0:52 
AnswerRe: How can i send io stream to specific USB Pin
Dave Kreskowiak3-Feb-11 2:24
mveDave Kreskowiak3-Feb-11 2:24 
GeneralRe: How can i send io stream to specific USB Pin
Yanshof3-Feb-11 2:41
Yanshof3-Feb-11 2:41 
GeneralRe: How can i send io stream to specific USB Pin
Paladin20003-Feb-11 3:33
Paladin20003-Feb-11 3:33 
GeneralRe: How can i send io stream to specific USB Pin
Dave Kreskowiak3-Feb-11 3:46
mveDave Kreskowiak3-Feb-11 3:46 
QuestionHow to get a list of all the APIs exposed by a web service? Pin
Aseem Sharma2-Feb-11 22:33
Aseem Sharma2-Feb-11 22:33 
AnswerRe: How to get a list of all the APIs exposed by a web service? Pin
Ray Cassick3-Feb-11 5:39
Ray Cassick3-Feb-11 5:39 
QuestionProblem with multirow selection in DataGridView control Pin
sandeepkavade2-Feb-11 22:14
sandeepkavade2-Feb-11 22:14 
QuestionHow to run a Command and retrieve data from it ? Pin
All Time Programming2-Feb-11 21:01
All Time Programming2-Feb-11 21:01 
AnswerRe: How to run a Command and retrieve data from it ? Pin
Richard MacCutchan2-Feb-11 21:58
mveRichard MacCutchan2-Feb-11 21:58 
GeneralRe: How to run a Command and retrieve data from it ? Pin
All Time Programming2-Feb-11 22:38
All Time Programming2-Feb-11 22:38 
AnswerRe: How to run a Command and retrieve data from it ? Pin
Pravin Patil, Mumbai2-Feb-11 22:17
Pravin Patil, Mumbai2-Feb-11 22:17 

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.