c# - 将 Application Insights 与 Windows 10 IoT 核心版结合使用

标签 c# azure azure-application-insights windows-10-iot-core

有一个关于在 Windows 应用程序中使用 Application Inights 的出色指南:Application Insights for Windows Phone and Store apps .

将 Application Insight 与 Windows 10 IoT 核心版结合使用有何最佳实践?我发现一个有趣的用法,即使用 Application Insigts 作为一种易于使用的事件日志记录机制来监视 headless 应用程序的运行状态。

最佳答案

这是我的发现。

请勿使用:WindowsAppInitializer.InitializeAsync("1234567-1111-1234-1234-1234567890ab"); 初始化 Application Insights,因为这会导致 IoT 应用程序崩溃。

我用了这样的东西:

public sealed class StartupTask : IBackgroundTask
{
    private BackgroundTaskDeferral _defferal;

    internal static TelemetryClient TelemetryClient = new TelemetryClient();


    public StartupTask()
    {
        TelemetryClient.InstrumentationKey = "1234567-1111-1234-1234-1234567890ab";

    }

    public async void Run(IBackgroundTaskInstance taskInstance)
    {
        var cancellationTokenSource = new System.Threading.CancellationTokenSource();
        taskInstance.Canceled += TaskInstance_Canceled;

        _defferal = taskInstance.GetDeferral();
        ... [insert your code]...
    }
}

要使用应用程序洞察,我只需使用 StartupTask.TelemetryClient.TrackEvent("Some event") 或其他一些我需要的 App Insight 方法。

关于c# - 将 Application Insights 与 Windows 10 IoT 核心版结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33064082/

相关文章:

C#:方法故障(没有可中断或继续的封闭循环)

c# - 为什么 BitConverter 在转换 float 和字节时似乎返回不正确的结果?

c# - 从 Microsoft.Azure.DocumentDb 迁移到 Microsoft.Azure.Cosmos 以进行数据访问。并非所有选项都可用

azure - 如何将诊断数据发送到 Application Insights? (自动化部署)

azure - 如何从AI日志中排除参数?

c# - 排程优化

c# - 输入特定字符的文本框问题

sql-server - 如何在Azure数据工厂上使用查询If Else条件?

azure - 需要获取上次事件日期或某个日期以在 azuredevops 中显示不活动的项目

c# - ApplicationInsights TelemetryClient 在调试时初始化很慢