本文整理汇总了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;
}
示例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();
}
示例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");
}
}
});
}