Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
GeneralRe: Statistical Functions in C# Pin
Kevin McFarlane6-Oct-03 10:37
Kevin McFarlane6-Oct-03 10:37 
GeneralRe: Statistical Functions in C# Pin
leppie6-Oct-03 12:31
leppie6-Oct-03 12:31 
GeneralRe: Statistical Functions in C# Pin
Donald_a8-Oct-03 3:40
Donald_a8-Oct-03 3:40 
Generalabout lock Pin
yyf6-Oct-03 5:52
yyf6-Oct-03 5:52 
GeneralRe: about lock Pin
jparsons6-Oct-03 6:21
jparsons6-Oct-03 6:21 
GeneralRe: about lock Pin
Daniel Turini6-Oct-03 6:30
Daniel Turini6-Oct-03 6:30 
GeneralRe: about lock Pin
jparsons6-Oct-03 6:36
jparsons6-Oct-03 6:36 
GeneralRe: about lock Pin
yyf6-Oct-03 7:39
yyf6-Oct-03 7:39 
Thanks for all your response. Sorry, I didn't make myself clear.

Actually I want to change the value of status in the lock block. I need to lock it in case some one else are using it.

so it should be something like that:

class MyClass<br />
{<br />
<br />
private object status = null;<br />
private object status0 = new object(0);<br />
private object status1 = new object(1);<br />
private object status2 = new object(2);<br />
<br />
myfunc()<br />
{<br />
...<br />
lock ( status ) {<br />
status = status1;<br />
}<br />
...<br />
}<br />
<br />
}


It has problem as I mentioned.

Maybe I should change it to:

status = new object(0);<br />
lock ( status )<br />
{<br />
status = status1;<br />
}


Another quick question:
From the help in .Net, it suggests I can use either this or typeof(class). But I don't understand how to use "typeof(class)"; I tried "lock ( this )", it worked. But I wonder how about if I have different variables in one class to protect. If I use "lock (this)", it'll bring up some unnecessary blocks. Right? So what should I do in this case?

Thank you very much.
GeneralRe: about lock Pin
jparsons6-Oct-03 13:02
jparsons6-Oct-03 13:02 
GeneralRe: about lock Pin
yyf7-Oct-03 6:03
yyf7-Oct-03 6:03 
QuestionA datatype/some way for 256 bit values? Pin
Fang@Illusion6-Oct-03 5:42
Fang@Illusion6-Oct-03 5:42 
AnswerRe: A datatype/some way for 256 bit values? Pin
Daniel Turini6-Oct-03 6:37
Daniel Turini6-Oct-03 6:37 
GeneralRe: A datatype/some way for 256 bit values? Pin
Fang@Illusion6-Oct-03 7:55
Fang@Illusion6-Oct-03 7:55 
AnswerRe: A datatype/some way for 256 bit values? Pin
leppie6-Oct-03 7:06
leppie6-Oct-03 7:06 
GeneralRe: A datatype/some way for 256 bit values? Pin
jparsons6-Oct-03 5:42
jparsons6-Oct-03 5:42 
GeneralRe: A datatype/some way for 256 bit values? Pin
Fang@Illusion8-Oct-03 9:01
Fang@Illusion8-Oct-03 9:01 
GeneralDirectoryTreeView with CheckBoxes Pin
j-hannemann6-Oct-03 4:30
j-hannemann6-Oct-03 4:30 
GeneralGetting CheckBox control in DataGrid Pin
brian41906-Oct-03 3:51
brian41906-Oct-03 3:51 
GeneralContext Menu Pin
.gonad6-Oct-03 3:31
.gonad6-Oct-03 3:31 
GeneralRe: Context Menu Pin
mistery226-Oct-03 10:13
mistery226-Oct-03 10:13 
GeneralRe: Context Menu Pin
.gonad6-Oct-03 12:43
.gonad6-Oct-03 12:43 
GeneralIcons in a c# gui Pin
Big Trev6-Oct-03 2:14
Big Trev6-Oct-03 2:14 
GeneralRe: Icons in a c# gui Pin
netclectic6-Oct-03 3:42
netclectic6-Oct-03 3:42 
GeneralRe: Icons in a c# gui Pin
mistery226-Oct-03 10:19
mistery226-Oct-03 10:19 
GeneralcomboBox.SelectedIndex in Win2000 vs. XP Pin
misiek6-Oct-03 2:08
misiek6-Oct-03 2:08 

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.