Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: SetWindowLong and SetWindowPos Pin
J. Dunlap16-Jun-03 8:02
J. Dunlap16-Jun-03 8:02 
GeneralRe: Showing a Form as a drop-down menu Pin
A.Wegierski15-Jun-03 22:54
A.Wegierski15-Jun-03 22:54 
GeneralRe: Showing a Form as a drop-down menu Pin
J. Dunlap16-Jun-03 7:47
J. Dunlap16-Jun-03 7:47 
GeneralArrayLists & multithreading... Pin
viperxp15-Jun-03 5:56
viperxp15-Jun-03 5:56 
GeneralRe: ArrayLists & multithreading... Pin
leppie15-Jun-03 6:44
leppie15-Jun-03 6:44 
GeneralRe: ArrayLists & multithreading... Pin
Arjan Einbu15-Jun-03 11:46
Arjan Einbu15-Jun-03 11:46 
GeneralRe: ArrayLists & multithreading... Pin
viperxp15-Jun-03 23:24
viperxp15-Jun-03 23:24 
GeneralRe: ArrayLists & multithreading... Pin
James T. Johnson16-Jun-03 0:10
James T. Johnson16-Jun-03 0:10 
viperxp wrote:
I ahve looked at both the Synchronized()

The Synchronized() method returns an instance of an ArrayList which takes care not to let only one operation run at a time.

The SyncRoot property returns an object which you can use to do your own locking (by using the lock keyword for instance).

ArrayList syncList = ArrayList.Synchronized(theList);
 
... 
 
// Let methods be called willy-nilly, 
// the synchronized wrapper will be automatically protected
And a second demo:

ArrayList theList = ...;
 
...
 
lock(theList.SyncRoot)
{
  // use 'theList' and be assured that only 
  // this thread is inside of this block
}
I prefer using lock, because it makes it very obvious that the code within is protected instead of trying to trace your steps through code to see whether you forgot to create the Synchronized wrapper.

The only advantage I can think of using the synchronized wrapper would be if you were performing lots of operations in a row where it didn't matter if other threads accessed the list in between those operations.

James

"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him

GeneralRe: ArrayLists & multithreading... Pin
viperxp16-Jun-03 2:53
viperxp16-Jun-03 2:53 
GeneralRe: ArrayLists & multithreading... Pin
James T. Johnson16-Jun-03 3:13
James T. Johnson16-Jun-03 3:13 
GeneralRe: ArrayLists & multithreading... Pin
viperxp16-Jun-03 7:10
viperxp16-Jun-03 7:10 
QuestionSimple inheritance? Pin
mcgahanfl15-Jun-03 2:27
mcgahanfl15-Jun-03 2:27 
AnswerRe: Simple inheritance? Pin
leppie15-Jun-03 3:54
leppie15-Jun-03 3:54 
GeneralRe: Simple inheritance? Pin
mcgahanfl15-Jun-03 17:14
mcgahanfl15-Jun-03 17:14 
GeneralWeb service performance... Pin
Matt Gullett15-Jun-03 2:25
Matt Gullett15-Jun-03 2:25 
GeneralRe: Web service performance... Pin
Kannan Kalyanaraman15-Jun-03 3:41
Kannan Kalyanaraman15-Jun-03 3:41 
GeneralRe: Web service performance... Pin
Matt Gullett15-Jun-03 3:47
Matt Gullett15-Jun-03 3:47 
GeneralRe: Web service performance... Pin
Kannan Kalyanaraman15-Jun-03 17:01
Kannan Kalyanaraman15-Jun-03 17:01 
GeneralRe: Web service performance... Pin
Rocky Moore15-Jun-03 23:18
Rocky Moore15-Jun-03 23:18 
GeneralRe: Web service performance... Pin
Matt Gullett15-Jun-03 23:35
Matt Gullett15-Jun-03 23:35 
GeneralDynamic object cloneing. Pin
Peter Kiss15-Jun-03 1:07
Peter Kiss15-Jun-03 1:07 
GeneralC# Service won't start Pin
gek_at14-Jun-03 23:59
gek_at14-Jun-03 23:59 
GeneralRe: C# Service won't start Pin
mcgahanfl15-Jun-03 2:16
mcgahanfl15-Jun-03 2:16 
GeneralRe: C# Service won't start Pin
gek_at15-Jun-03 3:20
gek_at15-Jun-03 3:20 
GeneralRe: C# Service won't start Pin
mcgahanfl15-Jun-03 3:53
mcgahanfl15-Jun-03 3:53 

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.