--- title: 'C# 背景同步執行' disqus: hackmd --- UWP 背景同步執行 === --- 今天要在UWP上做一個背景執行的功能 在這裡做個紀錄 > 拉個 async 函式出來做 > 在要用到的地方加上 DisplayBG(); > 執行 async 類型的函式時,遇到 await 就會跳回原本執行 DisplayBG() 的地方,並在背景執行。 ```C#= private async void DisplayBG() { settingBtn = true; await Task.Delay(1000); settingBtn = false; } ``` > 在設定 settingBtn 值為 true 後, > 一秒鐘後會更改為 false。 ###### tags: `UWP` `C#`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up