Here are the examples of the csharp api System.Threading.Tasks.TaskCompletionSource.TrySetResult(FlightPlanData) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : SimConnectFlightConnector.cs
with GNU General Public License v3.0
from nguyenquyhy
with GNU General Public License v3.0
from nguyenquyhy
private async void Simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data)
{
switch (data.dwRequestID)
{
case (int)DATA_REQUESTS.FLIGHT_PLAN:
if (!string.IsNullOrEmpty(data.szString))
{
logger.LogInformation($"Received flight plan {data.szString}");
var planName = data.szString;
if (planName == ".PLN")
{
logger.LogInformation("Flight plan is not read. Wait for 5s...");
await Task.Delay(5000);
simconnect.RequestSystemState(DATA_REQUESTS.FLIGHT_PLAN, "FlightPlan");
}
else
{
if (File.Exists(planName))
{
using var stream = File.OpenRead(planName);
var serializer = new XmlSerializer(typeof(FlightPlanDoreplacedentXml));
var flightPlan = serializer.Deserialize(stream) as FlightPlanDoreplacedentXml;
var flightPlanData = flightPlan.FlightPlan.ToData();
FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(flightPlanData));
flightPlanTcs?.TrySetResult(flightPlanData);
flightPlanTcs = null;
}
else
{
logger.LogWarning($"{planName} does not exist!");
FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(null));
flightPlanTcs?.TrySetResult(null);
flightPlanTcs = null;
}
}
}
break;
}
}
19
Source : SimConnectFlightConnector.cs
with GNU General Public License v3.0
from nguyenquyhy
with GNU General Public License v3.0
from nguyenquyhy
private async void Simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data)
{
switch (data.dwRequestID)
{
case (int)DATA_REQUESTS.FLIGHT_PLAN:
if (!string.IsNullOrEmpty(data.szString))
{
logger.LogInformation($"Received flight plan {data.szString}");
var planName = data.szString;
if (planName == ".PLN")
{
logger.LogInformation("Flight plan is not read. Wait for 5s...");
await Task.Delay(5000);
simconnect.RequestSystemState(DATA_REQUESTS.FLIGHT_PLAN, "FlightPlan");
}
else
{
if (File.Exists(planName))
{
using var stream = File.OpenRead(planName);
var serializer = new XmlSerializer(typeof(FlightPlanDoreplacedentXml));
var flightPlan = serializer.Deserialize(stream) as FlightPlanDoreplacedentXml;
var flightPlanData = flightPlan.FlightPlan.ToData();
FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(flightPlanData));
flightPlanTcs?.TrySetResult(flightPlanData);
flightPlanTcs = null;
}
else
{
logger.LogWarning($"{planName} does not exist!");
FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(null));
flightPlanTcs?.TrySetResult(null);
flightPlanTcs = null;
}
}
}
break;
}
}