次のコードでは、その非同期voidメソッドを呼び出しています。コード次すべての実行を完了するために非同期メソッドで待機する方法
public void LoadSystemDetails(int clientId)
{
DataSystem.Name = "Salesforce System";
DataSystem.Description = "";
GetAllFields(clientId);
}
はGetAllFields
方法
public async void GetAllFields(int clientId)
{
this.DataSystem.SystemTables = new List<DataSystemTable>();
using (var forceClient = await ConnectToSalesforceByOAuth(clientId))
{
var SalesForceTable = new DataSystemTable
{
TableName = "Contact"
};
DataSystem.SystemTables.Add(SalesForceTable);
var contact = forceClient.DescribeAsync<SalesforceObject>("Contact");
var tableFields = new List<DataSystemField>();
foreach (var con in contact.Result.Fields)
{
tableFields.Add(new DataSystemField
{
ColumnName = con.Name,
});
}
SalesForceTable.EissSyncSystemFields = tableFields;
}
あり、iは以下のようにcallbackScript
を呼び出します。
callbackScript.AppendLine(string.Format("var destinationSystem ={0};", JsonConvert.SerializeObject(this.DestinationSystem, Formatting.Indented)));
DestinationSystem
はLoadSystemDetails
を呼んでいます。同様にDestinationSystem.LoadSystemDetails(clientId)
callbackScript
実行時にはusing (var forceClient = await ConnectToSalesforceByOAuth(clientId))
行が実行されます。 SystemTables
には値がありません。それはName
とDescription
を持っています。
ここで私はGetAllFields
を完了するためにLoadSystemDetails
を待つ必要があります。
どうすればいいですか。私を助けてください。おかげさまで