Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: Namespace and Dataset! Pin
Paul Conrad28-Oct-07 16:53
professionalPaul Conrad28-Oct-07 16:53 
QuestionLicensing in .NET Pin
danielk_28-Oct-07 2:33
danielk_28-Oct-07 2:33 
AnswerRe: Licensing in .NET Pin
Scott Dorman28-Oct-07 3:24
professionalScott Dorman28-Oct-07 3:24 
GeneralRe: Licensing in .NET Pin
jmcc2k24-Nov-10 17:37
jmcc2k24-Nov-10 17:37 
QuestionGraph Pin
babbelfisken28-Oct-07 2:05
babbelfisken28-Oct-07 2:05 
AnswerRe: Graph Pin
Robert Rohde28-Oct-07 2:10
Robert Rohde28-Oct-07 2:10 
QuestionArray as a buffer in multithreading Pin
szolDat28-Oct-07 1:37
szolDat28-Oct-07 1:37 
AnswerRe: Array as a buffer in multithreading Pin
Robert Rohde28-Oct-07 2:21
Robert Rohde28-Oct-07 2:21 
Hi,

szolDat wrote:
I need to make the other threads recognize and not read the element that is being updated.

you could write a small wrapper around the stream to do this:
public class StreamLocker
{
    private MemoryStream _stream;
    private bool _isLocked;

    public StreamLocker(MemoryStream stream)
    {
        _stream = stream;
        _isLocked = false;
    }

    public MemoryStream LockStream()
    {
        lock (_stream)
        {
            if (_isLocked)
                return null; //if it is locked than just return null
                             //the caller can than continue with another instance
            return _stream; //if the caller gets a result than nobody else is working on it
        }
    }

    public void UnlockStream()
    {
        lock (_stream)
        {
            _isLocked = false;
        }
    }
}


Robert



AnswerRe: Array as a buffer in multithreading Pin
Guffa28-Oct-07 3:37
Guffa28-Oct-07 3:37 
GeneralRe: Array as a buffer in multithreading Pin
szolDat28-Oct-07 7:53
szolDat28-Oct-07 7:53 
AnswerRe: Array as a buffer in multithreading Pin
Guffa28-Oct-07 10:09
Guffa28-Oct-07 10:09 
AnswerRe: Array as a buffer in multithreading Pin
szolDat28-Oct-07 10:40
szolDat28-Oct-07 10:40 
GeneralRe: Array as a buffer in multithreading Pin
Guffa29-Oct-07 11:59
Guffa29-Oct-07 11:59 
AnswerRe: Array as a buffer in multithreading Pin
szolDat29-Oct-07 12:53
szolDat29-Oct-07 12:53 
QuestionControls Display Delay Pin
half-life28-Oct-07 0:39
half-life28-Oct-07 0:39 
AnswerRe: Controls Display Delay Pin
il_masacratore28-Oct-07 12:43
il_masacratore28-Oct-07 12:43 
GeneralRe: Controls Display Delay Pin
half-life28-Oct-07 12:47
half-life28-Oct-07 12:47 
QuestionHow to recored and play mp3 files? Pin
Mohsen Saad28-Oct-07 0:23
Mohsen Saad28-Oct-07 0:23 
AnswerRe: How to recored and play mp3 files? Pin
Giorgi Dalakishvili28-Oct-07 1:03
mentorGiorgi Dalakishvili28-Oct-07 1:03 
QuestionNotify Control Pin
Thaer Hamael27-Oct-07 21:29
Thaer Hamael27-Oct-07 21:29 
AnswerRe: Notify Control Pin
mav.northwind27-Oct-07 22:46
mav.northwind27-Oct-07 22:46 
GeneralRe: Notify Control Pin
Thaer Hamael27-Oct-07 23:07
Thaer Hamael27-Oct-07 23:07 
GeneralRe: Notify Control Pin
mav.northwind27-Oct-07 23:32
mav.northwind27-Oct-07 23:32 
AnswerRe: Notify Control Pin
Luc Pattyn28-Oct-07 5:11
sitebuilderLuc Pattyn28-Oct-07 5:11 
QuestionProgram that makes a Program Pin
sublimies27-Oct-07 18:20
sublimies27-Oct-07 18:20 

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.