Пример #1
0
        public async void RegisterConfiguration(ISmsConfiguration Config)
        {
            _server = new GsmCommMain(Config.Port, Config.BaudRate, 5000);
            do
            {
                await Task.Delay(100);

                if (_server.IsOpen())
                {
                    // connect event
                    OnServerConnected.CrossInvoke(this, new SmsServerConnected()
                    {
                        TimeConnected = DateTime.Now
                    });
                    break;
                }
                else
                {
                    try
                    {
                        _server.Open();
                    }
                    catch (Exception ex)
                    {
                        OnServerConnectionFail.CrossInvoke(this, new ServerConnectErrorEventArgs()
                        {
                            DatePosted = DateTime.Now,
                            guid       = Guid.NewGuid(),
                            Message    = ex.InnerException.Message ?? ex.Message
                        });
                    }
                }
            }while (true);
        }