Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is New() inherently threadsafe? Pin
Dennis C. Dietrich13-Dec-04 14:24
Dennis C. Dietrich13-Dec-04 14:24 
GeneralRe: Is New() inherently threadsafe? Pin
Shayne Husson13-Dec-04 15:42
Shayne Husson13-Dec-04 15:42 
GeneralResX File Difference Pin
SanShou13-Dec-04 12:31
SanShou13-Dec-04 12:31 
QuestionIndexed icon files, not supported in .net? Pin
Member 9613-Dec-04 11:41
Member 9613-Dec-04 11:41 
AnswerRe: Indexed icon files, not supported in .net? Pin
Dave Kreskowiak13-Dec-04 12:39
mveDave Kreskowiak13-Dec-04 12:39 
GeneralThreading + lock() question Pin
eyoung7013-Dec-04 9:15
eyoung7013-Dec-04 9:15 
GeneralRe: Threading + lock() question Pin
Skynyrd13-Dec-04 9:26
Skynyrd13-Dec-04 9:26 
GeneralRe: Threading + lock() question Pin
eyoung7013-Dec-04 10:23
eyoung7013-Dec-04 10:23 
Here's what I've found, and I hope I tested this correctly:

1. if you lock an object and then simply call a method from inside the lock, the currentthread maintains the lock in the called method

2. if you lock an object and then spawn a new thread and attempt to access the locked resource from the new thread, you must wait until the initial thread releases the lock

How I determined this was to add "lock(lockedObject)" (yes, I know I shouldn't use it but its just for this test) to all three methods: 1. the initial method (Method1), 2. the called method (Method2), and 3. the method the new thread calls (Method3).

The initial thread obtains the lock and calls Method2, which also requests a lock on the object. Because the thread in Method2 matches that of Method1 (as determined by outputting the currentthread's name), control passes right through Method2's lock with no problem and executes whatever code I have inside its lock().

However, if I access the lock in Method1, spawn a new thread (naming it, so I can check the flow of control), and attempt to access the lock on Method3, it waits momentarily until control passes through Method1, thus releasing the lock on the object and allowing Method3 to obtain the lock. At that point, code inside Method3's lock begins to execute.

I hope this is a sound way of determining this. I am somewhat of a newbie when it comes to threading issues, and I'm having to learn a lot of stuff just by performing my own little tests. If anyone sees a problem with my methodology, please help me out.
GeneralRe: Threading + lock() question Pin
Dennis C. Dietrich13-Dec-04 11:06
Dennis C. Dietrich13-Dec-04 11:06 
GeneralRe: Threading + lock() question Pin
Dennis C. Dietrich13-Dec-04 11:24
Dennis C. Dietrich13-Dec-04 11:24 
GeneralRe: Threading + lock() question Pin
Daniel Turini13-Dec-04 21:18
Daniel Turini13-Dec-04 21:18 
GeneralPrinting web browser control to screen Pin
Judah Gabriel Himango13-Dec-04 8:23
sponsorJudah Gabriel Himango13-Dec-04 8:23 
GeneralSql Statment Problem with Char " ' " Pin
webhay13-Dec-04 7:15
webhay13-Dec-04 7:15 
GeneralRe: Sql Statment Problem with Char " ' " Pin
Judah Gabriel Himango13-Dec-04 8:26
sponsorJudah Gabriel Himango13-Dec-04 8:26 
GeneralRe: Sql Statment Problem with Char " ' " Pin
J4amieC13-Dec-04 22:11
J4amieC13-Dec-04 22:11 
GeneralRe: Sql Statment Problem with Char " ' " Pin
webhay13-Dec-04 22:31
webhay13-Dec-04 22:31 
QuestionCan we use C# for programing Graphics Environments? Pin
Kiran Satish13-Dec-04 5:53
Kiran Satish13-Dec-04 5:53 
AnswerRe: Can we use C# for programing Graphics Environments? Pin
Dave Kreskowiak13-Dec-04 6:08
mveDave Kreskowiak13-Dec-04 6:08 
GeneralRe: Can we use C# for programing Graphics Environments? Pin
Anonymous13-Dec-04 6:24
Anonymous13-Dec-04 6:24 
GeneralRe: Can we use C# for programing Graphics Environments? Pin
Dave Kreskowiak13-Dec-04 9:58
mveDave Kreskowiak13-Dec-04 9:58 
GeneralOleDbConnection question Pin
Dirso13-Dec-04 4:56
Dirso13-Dec-04 4:56 
GeneralRe: OleDbConnection question Pin
Heath Stewart13-Dec-04 5:19
protectorHeath Stewart13-Dec-04 5:19 
GeneralRe: OleDbConnection question Pin
Skynyrd13-Dec-04 5:36
Skynyrd13-Dec-04 5:36 
Generalchanging the text colour in datagrid row (C#) Pin
steve_rm13-Dec-04 4:07
steve_rm13-Dec-04 4:07 
GeneralRe: changing the text colour in datagrid row (C#) Pin
tojamismis13-Dec-04 6:16
tojamismis13-Dec-04 6:16 

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.