Click here to Skip to main content
16,006,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help with socket problem... Pin
Aaron Dilliard12-Apr-06 9:19
Aaron Dilliard12-Apr-06 9:19 
AnswerRe: Help with socket problem... Pin
leppie12-Apr-06 19:40
leppie12-Apr-06 19:40 
QuestionI need some help with DBNull and checkboxes Pin
Tom Wright12-Apr-06 9:03
Tom Wright12-Apr-06 9:03 
AnswerRe: I need some help with DBNull and checkboxes Pin
junglerover7712-Apr-06 14:11
junglerover7712-Apr-06 14:11 
GeneralRe: I need some help with DBNull and checkboxes Pin
Tom Wright13-Apr-06 4:21
Tom Wright13-Apr-06 4:21 
Questionfull error "Automation server can't create object" Pin
hasantayyar12-Apr-06 8:53
hasantayyar12-Apr-06 8:53 
Questionhow to create a floating toolbar in c#? Pin
Susuko12-Apr-06 8:52
Susuko12-Apr-06 8:52 
QuestionThreading help? Pin
eric_tran12-Apr-06 8:13
eric_tran12-Apr-06 8:13 
Please help this. There are 2 errors at Thread creation.
I'd like to pass ArrayList to thread.


using System;<br />
using System.Threading;<br />
using System.Collections;<br />
namespace ConsoleApplication2<br />
{<br />
	class Program<br />
<br />
	{<br />
		static object lockObject;<br />
<br />
		static void Main(string[] args)<br />
<br />
		{	 <br />
<br />
<br />
			ArrayList space = new ArrayList();	<br />
<br />
			for (int i = 1; i <= 10  ; i++)<br />
			{<br />
				space.Add(i);<br />
			 <br />
			}		<br />
<br />
			lockObject = new object();				 <br />
			 <br />
<br />
 			Thread t1 = new Thread(new ParameterisedThreadStart(AccessData));		      	                t1.Start(space);<br />
<br />
			Thread.Sleep(20*1000);<br />
<br />
		}<br />
<br />
	 <br />
		<br />
		public static void AccessData(object param)<br />
		{<br />
//			Thread.CurrentThread.IsBackground = true;<br />
			 <br />
			ArrayList list = (ArrayList)param;<br />
					<br />
			lock (lockObject)<br />
			{<br />
				Random rand = new Random();<br />
		<br />
				int x = rand.Next(list.Count);<br />
				list.Remove(x);<br />
				Console.WriteLine("x = " + x);<br />
						<br />
				int y = rand.Next(list.Count);<br />
				list.Remove(y);<br />
				Console.WriteLine("y = " + y);<br />
		<br />
				int newNumber = x + y;<br />
				Console.WriteLine("newNumber = " + newNumber);<br />
		<br />
				list.Add(newNumber);<br />
		<br />
		<br />
		<br />
				foreach (int inte in list)<br />
					Console.WriteLine(inte);<br />
		<br />
			}<br />
						<br />
		 <br />
		 <br />
		}<br />
			<br />
	}<br />
}<br />


eric
AnswerRe: Threading help? Pin
Judah Gabriel Himango12-Apr-06 8:26
sponsorJudah Gabriel Himango12-Apr-06 8:26 
GeneralRe: Threading help? Pin
eric_tran12-Apr-06 8:37
eric_tran12-Apr-06 8:37 
GeneralRe: Threading help? Pin
Dan Neely12-Apr-06 8:55
Dan Neely12-Apr-06 8:55 
GeneralRe: Threading help? Pin
eric_tran12-Apr-06 8:58
eric_tran12-Apr-06 8:58 
GeneralRe: Threading help? Pin
Judah Gabriel Himango12-Apr-06 9:06
sponsorJudah Gabriel Himango12-Apr-06 9:06 
GeneralRe: Threading help? Pin
eric_tran12-Apr-06 9:08
eric_tran12-Apr-06 9:08 
QuestionTooltip does not show up Pin
smurfy3412-Apr-06 7:35
smurfy3412-Apr-06 7:35 
AnswerRe: Tooltip does not show up Pin
Manas Bhardwaj12-Apr-06 23:15
professionalManas Bhardwaj12-Apr-06 23:15 
GeneralRe: Tooltip does not show up Pin
smurfy3414-Apr-06 4:19
smurfy3414-Apr-06 4:19 
AnswerRe: Tooltip does not show up Pin
lvanerstrom14-Apr-06 8:18
lvanerstrom14-Apr-06 8:18 
GeneralRe: Tooltip does not show up Pin
smurfy3414-Apr-06 9:14
smurfy3414-Apr-06 9:14 
QuestionSynchronization thread help? Pin
eric_tran12-Apr-06 7:28
eric_tran12-Apr-06 7:28 
AnswerRe: Synchronization thread help? Pin
Judah Gabriel Himango12-Apr-06 7:43
sponsorJudah Gabriel Himango12-Apr-06 7:43 
GeneralRe: Synchronization thread help? Pin
eric_tran12-Apr-06 8:11
eric_tran12-Apr-06 8:11 
GeneralRe: Synchronization thread help? Pin
Judah Gabriel Himango12-Apr-06 8:25
sponsorJudah Gabriel Himango12-Apr-06 8:25 
GeneralRe: Synchronization thread help? Pin
eric_tran12-Apr-06 8:29
eric_tran12-Apr-06 8:29 
GeneralRe: Synchronization thread help? Pin
Judah Gabriel Himango12-Apr-06 9:07
sponsorJudah Gabriel Himango12-Apr-06 9:07 

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.