Beispiel #1
0
        private Task<bool> DeserializeAsync()
        {
            return Task.Run(() =>
            {
                if (File.Exists(@"_kitchenTimer.bin"))
                {
                    IFormatter formatter = new BinaryFormatter();

                    using (FileStream fs = new FileStream(@"_kitchenTimer.bin", FileMode.Open))
                    {
                        _kitchenTimer = (KitchenTimer)formatter.Deserialize(fs);
                    }
                    return true;
                }
                return false;
            });
        }
Beispiel #2
0
        private async void InitializeAfterDeserialization()
        {
            if (!await DeserializeAsync())
            {
                _kitchenTimer = new KitchenTimer();
            }
            else
            {
                InitializeTextBoxesFromTimeInterval();
            }

            _kitchenTimer.TimeTickEvent += _kitchenTimer_TimeTickEvent;
            _kitchenTimer.TimesOutEvent += _kitchenTimer_TimesOutEvent;
            InitializeTextBoxesNumericCheck();
        }