【发布时间】:2018-12-15 16:16:41
【问题描述】:
我声明了一个公共静态字符串,并将变量放入函数中以了解我的同步状态。我的问题是变量不会覆盖。我知道这是一个静态变量。我不知道如何覆盖变量或在 public static async void 中声明一个非静态变量,以便我知道同步的状态。我将在我的 xaml 中显示状态。
public class SyncFunction
{
public static string status; //This will display status of every function below
public static async void SyncUser(string host, string database, string contact, string ipaddress, byte[] pingipaddress){
... // Function here
status = "Syncing user";
}
public static async void SyncHost(string host, string database, string contact, string ipaddress, byte[] pingipaddress){
... // Function here
status = "Syncing host";
}
}
在我的 XAML.CS 中将是:
lblStatus.text = SyncFunction.status; //will display the status of my sync
【问题讨论】:
-
您多久执行一次最后一条语句?它只会分配一次当前值。您可能需要设置依赖项
标签: c# xamarin xamarin.forms xamarin.android