Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dispose method Help needed Pin
agmb11-Apr-06 6:06
agmb11-Apr-06 6:06 
AnswerRe: Dispose method Help needed Pin
Guffa11-Apr-06 7:11
Guffa11-Apr-06 7:11 
QuestionHow to do this? Pin
eric_tran11-Apr-06 2:37
eric_tran11-Apr-06 2:37 
AnswerRe: How to do this? Pin
thomasa11-Apr-06 3:06
thomasa11-Apr-06 3:06 
GeneralRe: How to do this? Pin
eric_tran11-Apr-06 3:19
eric_tran11-Apr-06 3:19 
GeneralRe: How to do this? Pin
J4amieC11-Apr-06 3:47
J4amieC11-Apr-06 3:47 
GeneralRe: How to do this? Pin
eric_tran12-Apr-06 1:23
eric_tran12-Apr-06 1:23 
GeneralRe: How to do this? Pin
thomasa11-Apr-06 4:17
thomasa11-Apr-06 4:17 
hehe, shurly, but your questions should be more spesific.

First, you need to know how many thread's you have to youse.

Let's asume that you should youse 2 threads.

Use an ArrayList with 1000 records with values from 1 to 1000.

The ArrayList can only be accessed by on thread at a time, so you need a parameter that determen that the
ArrayList is available for accessing.

lets say it is a
bool bIsAccessable = true;

So, the first thread starts, it looks if bIsAccessable is true, if so it sets it to false.

The second thread starts, it looks if bIsAccessable is true, but it isen't so it has to wait,
so now you need a timer, that should hold the thread for some millisecound, and then se if bIsAccessable is true, and so one and so one.

the first thread that know has access to the ArrayList,
gets the length of the ArrayList and creats a 1 random number, with max value of ArrayList.Count (1000)
Get's the rows value, and removes it from the the ArrayList, then
stores the value. Then it should get a new random number, whit max value of ArrayList.Count (that now is 999)
Get's the rows value, and removes the row from the the ArrayList.


Now the first thread can let go of the ArrayList becouse it has it's 2 numbers, so it sets the bIsAccessable to true.

Now the second thread can access the ArrayList, meenwhile the first thread calculates the sum of the 2 values it got.


I think there is a flau in my theory "What if both threads access the bIsAccessable" at the same time?"

So a think you need a thread that takes care of who that can access the ArrayList.

Well this should get you started.

Hope it helps
Thomas
AnswerRe: How to do this? Pin
Guffa11-Apr-06 7:34
Guffa11-Apr-06 7:34 
GeneralRe: How to do this? Pin
eric_tran12-Apr-06 1:36
eric_tran12-Apr-06 1:36 
QuestionMaking an app not function after some time Pin
naglbitur11-Apr-06 2:34
naglbitur11-Apr-06 2:34 
AnswerRe: Making an app not function after some time Pin
Timothy_198211-Apr-06 2:58
Timothy_198211-Apr-06 2:58 
AnswerRe: Making an app not function after some time Pin
thomasa11-Apr-06 3:04
thomasa11-Apr-06 3:04 
GeneralRe: Making an app not function after some time Pin
naglbitur11-Apr-06 3:57
naglbitur11-Apr-06 3:57 
GeneralRe: Making an app not function after some time Pin
naglbitur11-Apr-06 4:02
naglbitur11-Apr-06 4:02 
GeneralRe: Making an app not function after some time Pin
Gavin Roberts11-Apr-06 6:08
Gavin Roberts11-Apr-06 6:08 
AnswerRe: Making an app not function after some time Pin
Luis Alonso Ramos11-Apr-06 7:43
Luis Alonso Ramos11-Apr-06 7:43 
Questionhow to decalare varible Pin
papa198011-Apr-06 2:33
papa198011-Apr-06 2:33 
AnswerRe: how to decalare varible Pin
naglbitur11-Apr-06 2:42
naglbitur11-Apr-06 2:42 
GeneralRe: how to decalare varible Pin
papa198011-Apr-06 2:58
papa198011-Apr-06 2:58 
AnswerRe: how to decalare varible Pin
Rob Philpott11-Apr-06 6:50
Rob Philpott11-Apr-06 6:50 
QuestionLaunching application from another application Pin
zaboboa11-Apr-06 2:10
zaboboa11-Apr-06 2:10 
AnswerRe: Launching application from another application Pin
J4amieC11-Apr-06 2:28
J4amieC11-Apr-06 2:28 
GeneralRe: Launching application from another application Pin
zaboboa11-Apr-06 2:31
zaboboa11-Apr-06 2:31 
GeneralRe: Launching application from another application Pin
Jim Bennett11-Apr-06 5:20
Jim Bennett11-Apr-06 5:20 

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.