当前位置: 首页>>代码示例>>C#>>正文


C# Scheduler.SetInterfaceMode方法代码示例

本文整理汇总了C#中Scheduler.SetInterfaceMode方法的典型用法代码示例。如果您正苦于以下问题:C# Scheduler.SetInterfaceMode方法的具体用法?C# Scheduler.SetInterfaceMode怎么用?C# Scheduler.SetInterfaceMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scheduler的用法示例。


在下文中一共展示了Scheduler.SetInterfaceMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindCluster

        public static string FindCluster(string preferredCluster, HashSet<string> alternatives)
        {
            string s = preferredCluster;

            if (alternatives.Count > 0)
            {
                IScheduler scheduler = new Scheduler();
                scheduler.SetInterfaceMode(true, IntPtr.Zero);

                int sFree = GetFreeNodes(scheduler, preferredCluster);
                foreach (string a in alternatives)
                {
                    int fn = GetFreeNodes(scheduler, a);
                    if (fn > sFree)
                    {
                        s = a;
                        sFree = fn;
                    }
                }
            }

            return s;
        }
开发者ID:ahorn,项目名称:z3test,代码行数:23,代码来源:SubmissionWorker.cs

示例2: deleteExperiment

        private void deleteExperiment(object target, ExecutedRoutedEventArgs e)
        {
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            System.Windows.MessageBoxResult r =
              System.Windows.MessageBox.Show("Are you sure you want to delete the selected experiments?", "Sure?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (r == System.Windows.MessageBoxResult.Yes)
            {
                for (int i = 0; i < dataGrid.SelectedItems.Count; i++)
                {
                    int id = (int)((DataRowView)dataGrid.SelectedItems[i])["ID"];
                    SqlDataReader rd = null;

                    try
                    {
                        SqlCommand cmd = new SqlCommand("SELECT Cluster,ClusterJobID,SharedDir,Executor FROM Experiments WHERE ID=" + id.ToString(), sql);
                        rd = cmd.ExecuteReader();

                        if (rd.Read())
                        {
                            string cluster = (string)rd["Cluster"];
                            object jobid = rd["ClusterJobID"];
                            object sharedDir = rd["SharedDir"];
                            object executor = rd["Executor"];
                            rd.Close();

                            if (cluster != "" && !DBNull.Value.Equals(jobid))
                            {
                                try
                                {
                                    Scheduler scheduler = new Scheduler();
                                    scheduler.Connect(cluster);
                                    WindowInteropHelper helper = new WindowInteropHelper(this);
                                    scheduler.SetInterfaceMode(false, helper.Handle);
                                    scheduler.CancelJob((int)jobid, "Job aborted by user.");
                                }
                                catch { /* That's fine... */ }
                            }

                            if (!DBNull.Value.Equals(sharedDir) && !DBNull.Value.Equals(executor))
                            {
                                try
                                {
                                    File.Delete((string)sharedDir + "\\" + (string)executor);
                                }
                                catch { /* That's fine... */ }
                            }

                        }

                        cmd = new SqlCommand("DELETE FROM JobQueue WHERE ExperimentID=" + id.ToString() + ";" +
                                             "DELETE FROM Data WHERE ExperimentID=" + id.ToString() + ";" +
                                             "DELETE FROM Experiments WHERE ID=" + id.ToString(), sql);
                        cmd.CommandTimeout = 0;
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        string msg = String.Format("Error: could not delete experiment #{0} because of: {1} ", id, ex.Message);
                        r = System.Windows.MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    }
                    finally
                    {
                        if (rd != null) rd.Close();
                    }
                }
            }

            Mouse.OverrideCursor = null;

            updateDataGrid();
        }
开发者ID:ExiaHan,项目名称:z3test,代码行数:73,代码来源:MainWindow.xaml.cs

示例3: ScheduleJob

        private static void ScheduleJob(Scheduler scheduler, ISchedulerJob job) {
            var outWin = (IVsOutputWindow)HpcSupportPackage.GetGlobalService(typeof(IVsOutputWindow));

            IVsOutputWindowPane pane;
            if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) {
                pane.Activate();

                pane.OutputString("Submitting job " + job.Id + Environment.NewLine);
            }

            var shell = (IVsUIShell)HpcSupportPackage.GetGlobalService(typeof(SVsUIShell));
            IntPtr owner;
            if (ErrorHandler.Succeeded(shell.GetDialogOwnerHwnd(out owner))) {
                scheduler.SetInterfaceMode(false, owner);
            }


            ThreadPool.QueueUserWorkItem(x => {
                try {
                    scheduler.SubmitJob(job, null, null);
                } catch (Exception ex) {
                    string msg;
                    msg = "Failed to submit job " + ex.ToString();
                    if (pane != null) {
                        pane.OutputString(msg);
                    } else {
                        MessageBox.Show(msg, "Python Tools for Visual Studio");
                    }
                }
            });
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:31,代码来源:HpcLauncher.cs


注:本文中的Scheduler.SetInterfaceMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。