//private void BigButton_Click1(object sender, RoutedEventArgs e) //{ // bool result = false; // // var thread = new Thread(() => // //{ // Dispatcher.Invoke(new Action(() => // { // if (CMessageBox.Show("请通过手机验证", "eeeee", CMessageBoxButton.YesNO, CMessageBoxImage.None, CMessageBoxDefaultButton.Yes) == CMessageBoxResult.Yes) // result = true; // })); // //}); // // thread.Start(); // Console.WriteLine(result); //} private bool createMessageBox(StringBuilder path) { bool result = false; Dispatcher.Invoke(new Action(() => //BeginInvoke是异步操作,Invoke是同步操作。 { if (CMessageBox.Show("请通过手机验证\n" + ChangePath.ChangePaths(path), "e-Lock消息", CMessageBoxButton.YesNO, CMessageBoxImage.None, CMessageBoxDefaultButton.Yes) == CMessageBoxResult.Yes) { result = true; } })); return(result); }
private void requestMethod() { thread = new Thread(() => { ulong temp = 0; StringBuilder path = new StringBuilder(256); while (true) { bool isGet = CFunction.SimpleGetMessage(ref temp, path, 256); if (isGet == true && temp != 0) { StringBuilder devicepath = ChangePath.ChangePaths(path).Replace("\\", "/"); Dictionary <int, bool> dict = new Dictionary <int, bool>(); dict = isContain(devicepath); if (dict[1]) { if (dict[2]) { CFunction.SimpleReplyMessage(temp, true); } else { CFunction.SimpleReplyMessage(temp, false); } } else { //Window1 window = new Window1(devicepath, temp); //window.Show(); //if (System.Windows.MessageBox.Show("请通过手机验证", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes) if (createMessageBox(path)) { if (MainWindow.isSigined) { if (Post.SendCheck(devicepath.ToString(), "1")) { DateTime date = DateTime.Now; CFunction.SimpleReplyMessage(temp, true); permissions.Add(new Mypermission(devicepath, true, date)); } else { DateTime date = DateTime.Now; CFunction.SimpleReplyMessage(temp, false); permissions.Add(new Mypermission(devicepath, false, date)); } } else { System.Windows.MessageBox.Show("您还未登录!", "e-lock", MessageBoxButton.OK); } } else { DateTime date = DateTime.Now; CFunction.SimpleReplyMessage(temp, false); permissions.Add(new Mypermission(devicepath, false, date)); } } Thread.Sleep(TimeSpan.FromMilliseconds(10)); } else { Thread.Sleep(TimeSpan.FromMilliseconds(1000)); } } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); }