Click here to Skip to main content
15,890,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: Big Number Pin
Luc Pattyn15-May-12 13:16
sitebuilderLuc Pattyn15-May-12 13:16 
QuestionSkipping locked section already in use Pin
varunpandeyengg15-May-12 5:41
varunpandeyengg15-May-12 5:41 
GeneralRe: Skipping locked section already in use PinPopular
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 
this "chat" is a submission to my university, i can't use a database and need to user a server application that communicates witch tcp/ip (if i can use a database, this wouldn't be a problem Smile | :) )

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).

the point in making it a static class is that in this way all the threads would have access to the same list of users, but i've seen very strange comportment of this class, in the static constructor, the class instantiate and fills the list of contacts, i've put a breakpoint here and tested, for some reason, when i called the add method, the static constructor was not executed, with scared the sh*t out of me, everything was null, then, when the method returned (the method executed with success, even with the List<users> null, they were able to add to it, i don't know how) then the execution point moved to the static constructor, in my breakpoint.

after much test, i've found that when 2 threads call a method of this class, the secund call execute before the static constructor, i think it's a bug with my installation of visual studio, i prefer not to consider that this can occur i in a production environment, but just in case...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

GeneralRe: Skipping locked section already in use Pin
jschell15-May-12 8:56
jschell15-May-12 8:56 
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 

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.