public static void CreateDeviceIdentity() { string deviceName = "myFirstDevice"; AzureIoTHub.CreateDeviceIdentityAsync(deviceName).Wait(); Console.WriteLine($"Device with name '{deviceName}' was created/retrieved successfully"); }
private static void SimulateDeviceToSendD2CAndReceiveD2C() { CancellationTokenSource tokenSource = new CancellationTokenSource(); Console.CancelKeyPress += (s, e) => { e.Cancel = true; tokenSource.Cancel(); Console.WriteLine("Existing ..."); }; Console.WriteLine("Press CTRL+C to exit"); Task.WaitAll( AzureIoTHub.SendDeviceToCloudMessageAsync(tokenSource.Token), AzureIoTHub.ReceiveMessagesFromDeviceAsync(tokenSource.Token) ); }