Click here to Skip to main content
15,910,787 members
Home / Discussions / C#
   

C#

 
AnswerRe: Getting all data from commandline app Pin
Luc Pattyn11-Jan-10 7:01
sitebuilderLuc Pattyn11-Jan-10 7:01 
QuestionMerging or adding 2 different DataTables into Single DataTable Pin
K V Sekhar11-Jan-10 5:20
K V Sekhar11-Jan-10 5:20 
AnswerRe: Merging or adding 2 different DataTables into Single DataTable Pin
Dave Kreskowiak11-Jan-10 6:26
mveDave Kreskowiak11-Jan-10 6:26 
GeneralRe: Merging or adding 2 different DataTables into Single DataTable Pin
K V Sekhar11-Jan-10 15:39
K V Sekhar11-Jan-10 15:39 
GeneralRe: Merging or adding 2 different DataTables into Single DataTable Pin
Dave Kreskowiak11-Jan-10 17:29
mveDave Kreskowiak11-Jan-10 17:29 
QuestionBlocking Queue Pin
ika211-Jan-10 3:38
ika211-Jan-10 3:38 
AnswerRe: Blocking Queue Pin
harold aptroot11-Jan-10 3:41
harold aptroot11-Jan-10 3:41 
GeneralRe: Blocking Queue Pin
ika211-Jan-10 4:18
ika211-Jan-10 4:18 
Well, what I'm trying to do is a protocol stack implementation with layer abstraction.
So, the communication between layers should be a product/manager scenario. I don't know if I'm right.
So, I'm going to exchange my own objects in these queues.
I suppose, the buffer shouldn't be fixed sized. I know it can be less eficient, but the size should grow when it's needed.

The BlockingQueue implementation i have right now (I can't test it yet) is this:

public class BlockingQueue<T> : IEnumerable<T>
    {
        private int _count = 0;
        private Queue<T> _queue = new Queue<T>();

        public T Dequeue()
        {
            lock (_queue)
            {
                while (_count <= 0) 
                    Monitor.Wait(_queue);
                _count--;
                return _queue.Dequeue();
            }
        }

        public void Enqueue(T data)
        {
            if (data == null) 
                throw new ArgumentNullException("data");
            lock (_queue)
            {
                _queue.Enqueue(data);
                _count++;
                Monitor.Pulse(_queue);
            }
        }

        IEnumerator<T> IEnumerable<T>.GetEnumerator()
        {
            while (true) yield return Dequeue();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return ((IEnumerable<T>)this).GetEnumerator();
        }
    }


Regards
GeneralRe: Blocking Queue [modified] Pin
harold aptroot11-Jan-10 4:32
harold aptroot11-Jan-10 4:32 
AnswerRe: Blocking Queue Pin
Nicholas Butler11-Jan-10 5:31
sitebuilderNicholas Butler11-Jan-10 5:31 
QuestionProblem at second connection attempt Pin
sleepyman11-Jan-10 3:29
sleepyman11-Jan-10 3:29 
AnswerRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:06
mveOriginalGriff11-Jan-10 4:06 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 4:15
sleepyman11-Jan-10 4:15 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:37
mveOriginalGriff11-Jan-10 4:37 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 5:57
sleepyman11-Jan-10 5:57 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 8:19
mveOriginalGriff11-Jan-10 8:19 
QuestionRead in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:04
elmernite11-Jan-10 3:04 
AnswerMessage Closed Pin
11-Jan-10 3:14
stancrm11-Jan-10 3:14 
QuestionRe: Read in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:24
elmernite11-Jan-10 3:24 
QuestionWhat's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 2:34
arnold_w11-Jan-10 2:34 
AnswerRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 3:32
professional dan!sh 11-Jan-10 3:32 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:39
arnold_w11-Jan-10 3:39 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
dan!sh 11-Jan-10 3:45
professional dan!sh 11-Jan-10 3:45 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:50
arnold_w11-Jan-10 3:50 
GeneralRe: What's the best way to determine viewable portion of custom heading in DataGridView? Pin
arnold_w11-Jan-10 3:53
arnold_w11-Jan-10 3:53 

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.