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

C#

 
QuestionSkipping locked section already in use Pin
varunpandeyengg15-May-12 5:41
varunpandeyengg15-May-12 5:41 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 5:58
mvePIEBALDconsult15-May-12 5:58 
GeneralRe: Skipping locked section already in use Pin
varunpandeyengg15-May-12 6:13
varunpandeyengg15-May-12 6:13 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 6:29
mvePIEBALDconsult15-May-12 6:29 
GeneralRe: Skipping locked section already in use Pin
Sentenryu15-May-12 7:33
Sentenryu15-May-12 7:33 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 7:51
mvePIEBALDconsult15-May-12 7:51 
GeneralRe: Skipping locked section already in use Pin
Sentenryu15-May-12 8:19
Sentenryu15-May-12 8:19 
GeneralRe: Skipping locked section already in use Pin
jschell15-May-12 8:56
jschell15-May-12 8:56 
Sentenryu wrote:
in theory it works with the static class, the problem is that i'm afraid it's
not safe, what happens if two users connected (so, two threads) request the
server to add a new user, then the server call the Add method 2 times
simultaneously, the Add method writes a XML file and then reads it again (yes,
poor implementation, hopefully not mine).


That question has nothing to do with whether it is a singleton or not.

Sentenryu wrote:
but i've seen very strange comportment of this class


That has nothing to do with the correct behavior of the class. Could be something odd with how you were using the debugger, could be mismatch in classes, could bug in your code or something even more exotic like a bug in the debugger.


I wouldn't get to wrapped up in the implementation of the idea of a singleton.

Conceptually a singleton is a representation of a single instance of a class. Nothing magical about that. You can use a static class to manage the access to a single instance (a different class) without strictly implementing the singleton pattern and yet still conceptually implement it.
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 9:11
mvePIEBALDconsult15-May-12 9:11 
GeneralRe: Skipping locked section already in use Pin
Sentenryu15-May-12 9:34
Sentenryu15-May-12 9:34 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 9:50
mvePIEBALDconsult15-May-12 9:50 
GeneralRe: Skipping locked section already in use Pin
Sentenryu16-May-12 0:29
Sentenryu16-May-12 0:29 
AnswerRe: Skipping locked section already in use Pin
Ravi Bhavnani15-May-12 11:36
professionalRavi Bhavnani15-May-12 11:36 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 12:51
mvePIEBALDconsult15-May-12 12:51 
GeneralRe: Skipping locked section already in use Pin
Ravi Bhavnani15-May-12 13:04
professionalRavi Bhavnani15-May-12 13:04 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 14:32
mvePIEBALDconsult15-May-12 14:32 
GeneralRe: Skipping locked section already in use Pin
Ravi Bhavnani15-May-12 14:43
professionalRavi Bhavnani15-May-12 14:43 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 14:56
mvePIEBALDconsult15-May-12 14:56 
GeneralRe: Skipping locked section already in use Pin
Ravi Bhavnani15-May-12 15:02
professionalRavi Bhavnani15-May-12 15:02 
GeneralRe: Skipping locked section already in use Pin
PIEBALDconsult15-May-12 17:21
mvePIEBALDconsult15-May-12 17:21 
GeneralRe: Skipping locked section already in use Pin
jschell16-May-12 9:04
jschell16-May-12 9:04 
GeneralRe: Skipping locked section already in use Pin
Pete O'Hanlon15-May-12 8:20
mvePete O'Hanlon15-May-12 8:20 
GeneralRe: Skipping locked section already in use Pin
Sentenryu15-May-12 8:39
Sentenryu15-May-12 8:39 
GeneralRe: Skipping locked section already in use Pin
jschell15-May-12 9:02
jschell15-May-12 9:02 
GeneralRe: Skipping locked section already in use Pin
Pete O'Hanlon15-May-12 21:43
mvePete O'Hanlon15-May-12 21:43 

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.