Beispiel #1
0
        public void AddUnbemaltesEi(Ei ei)
        {
            lock (_unbemalteEier)
            {
                lock (_waitForUnbemaltesEi)
                {
                    while (_waitForUnbemaltesEi.Count > 0 && ei != null)
                    {
                        IOsterFabrikCallback callback = _waitForUnbemaltesEi.Dequeue();

                        if (IsCommunicationOpened(callback))
                        {
                            try
                            {
                                callback.ReturnUnbemaltesEi(ei);
                                ei = null;
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                            }
                        }
                    }
                }

                if (ei != null)
                {
                    _unbemalteEier.Enqueue(ei);
                    NotifyUnbemalteEier();
                }
            }
        }
Beispiel #2
0
        public void LookForNest()
        {
            IOsterFabrikCallback callback = GetCallbackChannel();

            lock (_nester)
            {
                if (_nester.Count > 0)
                {
                    Nest nest = _nester.Dequeue();
                    try
                    {
                        callback.ReturnNest(nest);
                        NotifyNester();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        _nester.Enqueue(nest);
                    }
                }
                else
                {
                    lock (_waitForNest)
                    {
                        _waitForNest.Enqueue(callback);
                    }
                }
            }
        }
Beispiel #3
0
        public void LookForSchokoHase()
        {
            IOsterFabrikCallback callback = GetCallbackChannel();

            lock (_schokoHasen)
            {
                if (_schokoHasen.Count > 0)
                {
                    SchokoHase hase = _schokoHasen.Dequeue();
                    try
                    {
                        callback.ReturnSchokoHase(hase);
                        NotifySchokoHasen();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        _schokoHasen.Enqueue(hase);
                    }
                }
                else
                {
                    lock (_waitForSchokoHase)
                    {
                        _waitForSchokoHase.Enqueue(callback);
                    }
                }
            }
        }
Beispiel #4
0
        public void LookForBemaltesEi()
        {
            IOsterFabrikCallback callback = GetCallbackChannel();

            lock (_bemalteEier)
            {
                if (_bemalteEier.Count > 0)
                {
                    Ei ei = _bemalteEier.Dequeue();
                    try
                    {
                        callback.ReturnBemaltesEi(ei);
                        NotifyBemalteEier();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        _bemalteEier.Enqueue(ei);
                    }
                }
                else
                {
                    lock (_waitForBemaltesEi)
                    {
                        _waitForBemaltesEi.Enqueue(callback);
                    }
                }
            }
        }
Beispiel #5
0
        public void AddNest(Nest nest)
        {
            lock (_nester)
            {
                lock (_waitForNest)
                {
                    while (_waitForNest.Count > 0 && nest != null)
                    {
                        IOsterFabrikCallback callback = _waitForNest.Dequeue();

                        if (IsCommunicationOpened(callback))
                        {
                            try
                            {
                                callback.ReturnNest(nest);
                                nest = null;
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                            }
                        }
                    }
                }

                if (nest != null)
                {
                    _nester.Enqueue(nest);
                    NotifyNester();
                }
            }
        }
Beispiel #6
0
        public void AddSchokoHase(SchokoHase schokoHase)
        {
            lock (_schokoHasen)
            {
                lock (_waitForSchokoHase)
                {
                    while (_waitForSchokoHase.Count > 0 && schokoHase != null)
                    {
                        IOsterFabrikCallback callback = _waitForSchokoHase.Dequeue();

                        if (IsCommunicationOpened(callback))
                        {
                            try
                            {
                                callback.ReturnSchokoHase(schokoHase);
                                schokoHase = null;
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                            }
                        }
                    }
                }

                if (schokoHase != null)
                {
                    _schokoHasen.Enqueue(schokoHase);
                    NotifySchokoHasen();
                }
            }
        }
Beispiel #7
0
 private bool IsCommunicationOpened(IOsterFabrikCallback callback)
 {
     return(((ICommunicationObject)callback).State == CommunicationState.Opened);
 }
Beispiel #8
0
 private bool IsCommunicationOpened(IOsterFabrikCallback callback)
 {
     return ((ICommunicationObject)callback).State == CommunicationState.Opened;
 }