gpt4 book ai didi

c# - 我收到此错误,并在可能的情况下需要帮助进行修复。我正在尝试构建我的项目以查看输出,但不会让我

转载 作者:行者123 更新时间:2023-12-03 08:41:05 27 4
gpt4 key购买 nike

CS0029无法将类型“System.Threading.Timer”隐式转换为“Windows.UI.Xaml.DispatcherTimer”
这是我收到的错误代码,我相信这是无法构建项目的原因。我的教授主持了一次变焦 session 并制作了一个youtube视频,这是他写的一些代码,我们结束了。

namespace DataCollector
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{

private DispatcherTimer timer;
MeasureLengthDevice measurementDevice = null;
MainViewData displayData = new MainViewData();

Frame frame = null;
MainPage page = null;

public MainPage()
{
this.InitializeComponent();
timer = new Timer(Timer_Tick, null, (int)TimeSpan.FromSeconds(1).TotalMilliseconds,
(int)TimeSpan.FromSeconds(15).TotalMilliseconds);
measurementDevice = new MeasureLengthDevice();

displayData = new MainViewData
{
Measurement = measurementDevice.ToString(),
History = measurementDevice.History
};

}

private void Button_Click(object sender, RoutedEventArgs e)
{
frame = (Frame)Window.Current.Content;
page = (MainPage)frame.Content;
measure.Text = measurementDevice.Measurement.ToString();
measureHistory.Text = measurementDevice.History;
}

private async void Timer_Tick(object state)
{
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
if (page != null)
{
page.measure.Text = measurementDevice.Measurement.ToString();
}
displayData.History = measurementDevice.History;
});
}
}
}

最佳答案

该代码显然是错误的,没有更多上下文就无法修复它。但是,您真的应该问您的教授,为什么它不起作用,而不是在Stack Overflow上发布您的问题。

关于c# - 我收到此错误,并在可能的情况下需要帮助进行修复。我正在尝试构建我的项目以查看输出,但不会让我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61451751/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com