Click here to Skip to main content
15,888,113 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 22:13
Member 120616007-Feb-16 22:13 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616008-Feb-16 0:11
Member 120616008-Feb-16 0:11 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Daniel Pfeffer8-Feb-16 2:07
professionalDaniel Pfeffer8-Feb-16 2:07 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616008-Feb-16 2:10
Member 120616008-Feb-16 2:10 
AnswerRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 21:47
professionalJochen Arndt7-Feb-16 21:47 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:52
Member 120616007-Feb-16 21:52 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 22:09
professionalJochen Arndt7-Feb-16 22:09 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 22:13
Member 120616007-Feb-16 22:13 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 22:36
professionalJochen Arndt7-Feb-16 22:36 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 23:26
Member 120616007-Feb-16 23:26 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 23:35
professionalJochen Arndt7-Feb-16 23:35 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 23:59
Member 120616007-Feb-16 23:59 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt8-Feb-16 0:19
professionalJochen Arndt8-Feb-16 0:19 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616008-Feb-16 0:20
Member 120616008-Feb-16 0:20 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt8-Feb-16 0:34
professionalJochen Arndt8-Feb-16 0:34 

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.