Click here to Skip to main content
15,912,400 members
Home / Discussions / C#
   

C#

 
Question(c#) Detection of encoding imported txt files ? Pin
Member 104109728-Feb-16 21:17
Member 104109728-Feb-16 21:17 
AnswerRe: (c#) Detection of encoding imported txt files ? Pin
Thomas Daniels8-Feb-16 21:34
mentorThomas Daniels8-Feb-16 21:34 
GeneralRe: (c#) Detection of encoding imported txt files ? Pin
Member 104109728-Feb-16 23:31
Member 104109728-Feb-16 23:31 
AnswerRe: (c#) Detection of encoding imported txt files ? Pin
Sascha Lefèvre8-Feb-16 21:54
professionalSascha Lefèvre8-Feb-16 21:54 
QuestionHow can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 10:11
sugarpasa8-Feb-16 10:11 
AnswerRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 11:24
professionalRichard Andrew x648-Feb-16 11:24 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 11:48
sugarpasa8-Feb-16 11:48 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 11:50
professionalRichard Andrew x648-Feb-16 11:50 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 12:41
sugarpasa8-Feb-16 12:41 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 12:15
professionalRichard Andrew x648-Feb-16 12:15 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa8-Feb-16 12:44
sugarpasa8-Feb-16 12:44 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x648-Feb-16 12:49
professionalRichard Andrew x648-Feb-16 12:49 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa9-Feb-16 6:12
sugarpasa9-Feb-16 6:12 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x649-Feb-16 6:19
professionalRichard Andrew x649-Feb-16 6:19 
QuestionScanning QR code Pin
Member 123142768-Feb-16 7:13
Member 123142768-Feb-16 7:13 
AnswerRe: Scanning QR code Pin
OriginalGriff8-Feb-16 8:09
mveOriginalGriff8-Feb-16 8:09 
AnswerRe: Scanning QR code Pin
Sascha Lefèvre8-Feb-16 8:15
professionalSascha Lefèvre8-Feb-16 8:15 
QuestionC# iTexSharp How to put PDF page number during creation PDF File Pin
Zefir18-Feb-16 2:38
Zefir18-Feb-16 2:38 
AnswerRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Richard MacCutchan8-Feb-16 3:17
mveRichard MacCutchan8-Feb-16 3:17 
GeneralRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Zefir18-Feb-16 3:27
Zefir18-Feb-16 3:27 
GeneralRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Richard MacCutchan8-Feb-16 3:50
mveRichard MacCutchan8-Feb-16 3:50 
QuestionIs this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:07
Member 120616007-Feb-16 21:07 
AnswerRe: Is this serial port class and how I use it thred safe? Pin
Daniel Pfeffer7-Feb-16 21:29
professionalDaniel Pfeffer7-Feb-16 21:29 
You have serialized calls to HASPClass.Query, and serialized calls to Tester.function1 and Tester.function2. If Tester is the only class using HASPClass, this should be thread-safe as far as calls to HASPClass.Query() are concerned.

My problem with your code is that function1 and function2 each use TWO calls to HASPClass.Query to perform their work. If you ever have a second class calling HASPClass.Query, it is entirely possiblethat this code will no longer be thread-safe:

C#
class Class2
{
    static readonly object m_lock = new object();

    public static function3()
    {
        lock(m_lock);
        HASPClass.Query();
        // task switch here - new thread calls Tester.function1()
        HASPClass.Query()
    }
}


In this case, it is quite possible that a call to Tester.function1 will intervene, corrupting the data read by Class2.function3.

You should redesign HASPClass so that the double call to Query() is itself an atomic operation.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.

--Winston Churchill

GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:41
Member 120616007-Feb-16 21:41 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Daniel Pfeffer7-Feb-16 22:10
professionalDaniel Pfeffer7-Feb-16 22:10 

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.