private async Task EvalTimer_ElapsedTask()
        {
            using (var tryLock = new TryLock(_lock))
            {
                if (!tryLock.HasAcquiredLock)
                {
                    return;
                }
                try
                {
                    string html = await browser.InvokeScriptAsync("eval", new string[] { "document.getElementById('nhmResponse').value;" });

                    if (!html.Contains("btcAddress"))
                    {
                        return;
                    }
                    var btcResp = JsonConvert.DeserializeObject <BtcResponse>(html);
                    if (btcResp.btcAddress != null)
                    {
                        var result = await ApplicationStateManager.SetBTCIfValidOrDifferent(btcResp.btcAddress);

                        var btcLoginDialog = new CustomDialog()
                        {
                            Title            = Translations.Tr("Login"),
                            OkText           = Translations.Tr("Ok"),
                            CancelVisible    = Visibility.Collapsed,
                            AnimationVisible = Visibility.Collapsed
                        };

                        if (result == ApplicationStateManager.SetResult.INVALID)
                        {
                            btcLoginDialog.Description = Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.");
                            btcLoginDialog.OKClick    += (s, e) => {
                                Process.Start(Links.Login);
                            };
                        }
                        else if (result == ApplicationStateManager.SetResult.CHANGED)
                        {
                            btcLoginDialog.Description = Translations.Tr("Login performed successfully. Feel free to start mining.");
                        }

                        CustomDialogManager.ShowModalDialog(btcLoginDialog);
                    }
                    else
                    {
                        var btcLoginDialog = new CustomDialog()
                        {
                            Title            = Translations.Tr("Login"),
                            OkText           = Translations.Tr("Ok"),
                            CancelVisible    = Visibility.Collapsed,
                            AnimationVisible = Visibility.Collapsed,
                            Description      = Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.")
                        };
                        btcLoginDialog.OKClick += (s, e) => {
                            Process.Start(Links.Login);
                        };
                        CustomDialogManager.ShowModalDialog(btcLoginDialog);
                    }
                    _evalTimer.Dispose();
                    Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        private async Task EvalTimer_ElapsedTask()
        {
            using (var tryLock = new TryLock(_lock))
            {
                if (!tryLock.HasAcquiredLock)
                {
                    return;
                }
                try
                {
#warning handle case for logged in sessions with/without btc
                    string html = await browser.InvokeScriptAsync("eval", new string[] { "document.getElementById('nhmResponse').value;" });

                    var webResponse = JsonConvert.DeserializeObject <Response>(html);
                    if (webResponse == null)
                    {
                        return;
                    }

                    // assume failure
                    var description = Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.");

                    if (webResponse.btcAddress != null)
                    {
                        var result = await ApplicationStateManager.SetBTCIfValidOrDifferent(webResponse.btcAddress);

                        if (result == ApplicationStateManager.SetResult.CHANGED)
                        {
                            description = Translations.Tr("Login performed successfully.");
                            Logger.Info("Login", $"Navigation and processing successfull.");
                        }
                        else
                        {
                            Logger.Error("Login", $"Btc address: {webResponse.btcAddress} was not saved. Result: {result}.");
                        }
                    }
                    else if (webResponse.error != null)
                    {
                        var error = webResponse.error;
                        Logger.Error("Login", "Received error: " + error);
                    }
                    else
                    {
                        Logger.Info("Login", $"Navigation and processing successfull. BTC wasn't retreived.");
                    }

                    var btcLoginDialog = new CustomDialog()
                    {
                        Title            = Translations.Tr("Login"),
                        OkText           = Translations.Tr("Ok"),
                        CancelVisible    = Visibility.Collapsed,
                        AnimationVisible = Visibility.Collapsed,
                        Description      = description
                    };
                    btcLoginDialog.OKClick += (s, e) =>
                    {
                        Process.Start(Links.Login);
                    };

                    CustomDialogManager.ShowModalDialog(btcLoginDialog);

                    _evalTimer.Dispose();
                    Close();
                }
                catch (Exception e)
                {
                    Logger.Error("Login", e.Message);
                }
            }
        }