using Dapper; using Microsoft.EntityFrameworkCore; using Models; using System.Collections.ObjectModel; using System.Configuration; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; namespace WpfApp4 { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { DispatcherTimer PutTimer; public MainWindow() { InitializeComponent(); PutTimer = new DispatcherTimer(); PutTimer.Tick += new EventHandler(PutTimer_Tick); PutTimer.Interval = TimeSpan.FromSeconds(60); //设置刷新的间隔时间 PutTimer.Start(); } private void PutTimer_Tick(object sender, EventArgs e) { this.Dispatcher.BeginInvoke(new Action(() => { //using (var context = new JobDbContext()) //{ // var connection = context.Database.GetDbConnection(); // var logs = connection.Query("select top 500 * from Logs"); // this.dataGrid1.ItemsSource = logs; //} })); } } }