AJBM Posted September 29, 2014 Report Share Posted September 29, 2014 Boas! Eu quero apresentar uma mensagem ao utilizador e passado algum tempo a mensagem desapareça. Estou a utilizar uma label para apresentar a mensagem (lblMsg) Eu tenho isto mas não está a funcionar lblMsg.Content = sms; Thread.Sleep(3000); lblMsg.Content = ""; Link to comment Share on other sites More sharing options...
nelsonr Posted September 29, 2014 Report Share Posted September 29, 2014 Boas, experimenta adicionar um Application.DoEvents() antes do thread.sleep, de forma a fazer o refresh do conteúdo do form antes de parar o thread Link to comment Share on other sites More sharing options...
AJBM Posted September 29, 2014 Author Report Share Posted September 29, 2014 Já tinha tentado isso não dá, diz que não contem esse método. Link to comment Share on other sites More sharing options...
Solution pikax Posted September 29, 2014 Solution Report Share Posted September 29, 2014 tens que ter a referencia a System.Windows.Forms.dll EDIT: ja que estas em wpf, se tiveres na .net 4.5, usa uma funcao async Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
AJBM Posted September 29, 2014 Author Report Share Posted September 29, 2014 tens que ter a referencia a System.Windows.Forms.dll funcionou. 👍 Eu estou a usar WPF esta solução será a mais correcta, porque supostamente estou a usar um método de forms? Link to comment Share on other sites More sharing options...
pikax Posted September 29, 2014 Report Share Posted September 29, 2014 Acho que a solucao mais correcta seria mesmo usar uma funcao async, mas depende da versao do .net que estejas a usar. Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
AJBM Posted September 29, 2014 Author Report Share Posted September 29, 2014 Eu já tentei usar BackgroundWorker mas não dá, diz que o componente já está numa thread Link to comment Share on other sites More sharing options...
pikax Posted September 29, 2014 Report Share Posted September 29, 2014 o que estas a tentar fazer? Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast." Link to comment Share on other sites More sharing options...
AJBM Posted September 30, 2014 Author Report Share Posted September 30, 2014 Optei por usar Application.DoEvents() resolve o problema. Obrigado pela ajuda 👍 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now