Forum Xamarin

Change Label after ButtonClicked event

Viplav04Viplav04 Member ✭✭

Hallo

I have an Init() function (called in Page Constructor) where I set the text value of a label. I have also some buttons which change the text of this label.
How to call the Init() function after a delay after the button has changed the text value? My buttons are async void .

async void OnBtnClicked(object sender, EventArgs e)
    {
      try
      {
        if(somecondition)
            Label.Text = "sometext";
        Thread.Sleep(2000);
        Init();
      }
      catch (Exception ex)
      {
        Debug.WriteLine(ex.Message);
      }
  }

My Label here changes directly to what it is in Init(). Need another way to call Init();

Best Answer

  • Viplav04Viplav04 Member ✭✭
    Accepted Answer

    Solved!

    used await Init();

    declared Init function as async Task Init( ){ }

Answers

  • Viplav04Viplav04 Member ✭✭
    Accepted Answer

    Solved!

    used await Init();

    declared Init function as async Task Init( ){ }

Sign In or Register to comment.