Click here to Skip to main content
16,005,826 members
Home / Discussions / C#
   

C#

 
Generalprinting a picture box in c# need source/help Pin
bob112513-Dec-04 19:02
bob112513-Dec-04 19:02 
GeneralRe: printing a picture box in c# need source/help Pin
Priest Of Psi14-Dec-04 2:31
Priest Of Psi14-Dec-04 2:31 
GeneralKeyWord and Reserved Word Pin
Amirzeb13-Dec-04 18:16
Amirzeb13-Dec-04 18:16 
GeneralRe: KeyWord and Reserved Word Pin
mitreviper13-Dec-04 19:14
mitreviper13-Dec-04 19:14 
GeneralReading data from WebResponse Pin
khchan13-Dec-04 16:01
khchan13-Dec-04 16:01 
GeneralRe: Reading data from WebResponse Pin
Daniel Turini13-Dec-04 21:15
Daniel Turini13-Dec-04 21:15 
QuestionIs New() inherently threadsafe? Pin
Shayne Husson13-Dec-04 13:08
Shayne Husson13-Dec-04 13:08 
AnswerRe: Is New() inherently threadsafe? Pin
Dennis C. Dietrich13-Dec-04 13:47
Dennis C. Dietrich13-Dec-04 13:47 
Shayne Husson wrote:
I am trying to get an understanding about making classes thread-safe.
Since the constructor is called just once for each instance of a class, does it follow that no other consideration needs to be given to ensure the constructor is thread-safe?


No. However the new Operator[^] is not the problem as it (as you already mentioned) just creates an object, invokes the constructor and returns a reference to the newly created object. This will be thread-safe as long as the constructor does not access any outside object (public MyClass() {} for example is no problem at all). But let's assume you have something like this:
public MyClass(object someObject)
{
  // some critical operation
}

If you use this constructor in a multithreaded scenario you might end up having concurrent access of someObject. Now if you don't have a synchronization mechanism one thread might end up accessing someObject in an inconsistent state. So ultimately the need for synchronization in the constructor really depends on if and what you're trying to do with any objects which are known outside the constructor.

Best regards
Dennis
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 
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 

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.