本文整理汇总了C#中XenAdmin.Actions.AsyncAction类的典型用法代码示例。如果您正苦于以下问题:C# AsyncAction类的具体用法?C# AsyncAction怎么用?C# AsyncAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncAction类属于XenAdmin.Actions命名空间,在下文中一共展示了AsyncAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BringDown
//private static void BringDown(AsyncAction action, PIF master, bool this_host, int hi)
//{
// ForSomeHosts(action, master, this_host, false, hi, BringDown);
//}
/// <summary>
/// Depurpose (set disallow_unplug=false) and remove the IP address from the given PIF.
/// </summary>
internal static void BringDown(AsyncAction action, PIF pif, int hi)
{
int mid = (action.PercentComplete + hi) / 2;
Depurpose(action, pif, mid);
ClearIP(action, pif, hi);
}
示例2: TaskPoller
/// <summary>
/// Polls the action regularly and updates the history item's progress from the task's progress,
/// scaled to a value between lo and hi.
/// </summary>
public TaskPoller(AsyncAction action, int lo, int hi)
{
_action = action;
_lo = lo;
if (hi < lo)
{
log.Warn("Squelching progress bar reversal.");
hi = lo + 1;
}
_scale = hi - lo;
}
示例3: ActionProgressDialog
public ActionProgressDialog(AsyncAction action, ProgressBarStyle progressBarStyle)
{
InitializeComponent();
this.action = action;
action.Completed += action_Completed;
action.Changed += action_Changed;
progressBar1.Style = progressBarStyle;
updateStatusLabel();
buttonCancel.Enabled = action.CanCancel;
ShowIcon = false;
HideTitleBarIcons();
}
示例4: Put
/// <summary>
/// HTTP PUT file from path to HTTP action f, updating action with progress every 500ms.
/// </summary>
/// <param name="action">Action on which to update the progress</param>
/// <param name="timeout">Timeout value in ms</param>
/// <param name="path">path of file to put</param>
public static String Put(AsyncAction action, int timeout, string path, string hostname, Delegate f, params object[] p)
{
Session session = action.Session;
action.RelatedTask = XenAPI.Task.create(session, "uploadTask", hostname);
try
{
HTTP.UpdateProgressDelegate progressDelegate = delegate(int percent)
{
action.Tick(percent, action.Description);
};
return Put(progressDelegate, action.GetCancelling, timeout, action.Connection,
action.RelatedTask, ref session, path, hostname, f, p);
}
finally
{
action.Session = session;
Task.destroy(session, action.RelatedTask);
}
}
示例5: GetTextColor
private Color GetTextColor(AsyncAction action)
{
Color textColor;
if (action == null || !action.StartedRunning) // not started yet
textColor = flickerFreeListBox1.ForeColor;
else if (!action.IsCompleted) // in progress
textColor = Color.Blue;
else textColor = action.Succeeded ? Color.Green : Color.Red; // completed
return textColor;
}
示例6: GetActionDescription
private static string GetActionDescription(AsyncAction action)
{
return !action.StartedRunning ? "" :
action.Exception == null
? action.Description
: action.Exception is CancelledException ? Messages.CANCELLED_BY_USER : action.Exception.Message;
}
示例7: CancelAction
private void CancelAction(AsyncAction action)
{
Program.AssertOnEventThread();
OnPageUpdated();
action.Changed -= singleAction_Changed;
action.Completed -= singleAction_Completed;
action.Cancel();
}
示例8: Depurpose
/// <summary>
/// Clear the disallow_unplug and ManagementPurpose on the given NIC.
/// </summary>
private static void Depurpose(AsyncAction action, PIF pif, int hi)
{
log.DebugFormat("Depurposing PIF {0} {1}...", pif.Name, pif.uuid);
action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_DEPURPOSING, pif.Name);
PIF p = (PIF)pif.Clone();
p.disallow_unplug = false;
p.ManagementPurpose = null;
p.SaveChanges(action.Session);
action.PercentComplete = hi;
log.DebugFormat("Depurposed PIF {0} {1}.", pif.Name, pif.uuid);
action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_DEPURPOSED, pif.Name);
}
示例9: BringUp
/// <summary>
/// Configure an IP address, management purpose, and set the disallow_unplug flag on the given existing_pif.
/// </summary>
/// <param name="new_pif">The source of the new IP details</param>
/// <param name="existing_pif">The PIF to configure</param>
internal static void BringUp(AsyncAction action, PIF new_pif, string new_ip, PIF existing_pif, int hi)
{
bool primary = string.IsNullOrEmpty(new_pif.ManagementPurpose);
int lo = action.PercentComplete;
int inc = (hi - lo) / (primary ? 2 : 3);
log.DebugFormat("Bringing PIF {0} {1} up as {2}/{3}, {4}, {5}...", existing_pif.Name, existing_pif.uuid,
new_ip, new_pif.netmask, new_pif.gateway, new_pif.DNS);
action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_BRINGING_UP, existing_pif.Name);
PIF p = (PIF)existing_pif.Clone();
p.disallow_unplug = !primary;
p.ManagementPurpose = new_pif.ManagementPurpose;
p.SaveChanges(action.Session);
action.PercentComplete = lo + inc;
ReconfigureIP(action, new_pif, existing_pif, new_ip, action.PercentComplete + inc);
if (!primary)
Plug(action, existing_pif, hi);
action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_BRINGING_UP_DONE, existing_pif.Name);
log.DebugFormat("Brought PIF {0} {1} up.", existing_pif.Name, existing_pif.uuid);
}
示例10: PropertiesDialogClosingEventArgs
public PropertiesDialogClosingEventArgs(AsyncAction action, bool startAction)
{
StartAction = startAction;
Action = action;
}
示例11: AddActionToSummary
void AddActionToSummary(AsyncAction action)
{
if (action == null)
return;
SrDescriptor srDescriptor;
actionSrDescriptorDict.TryGetValue(action, out srDescriptor);
if (srDescriptor == null)
return;
if (action.Succeeded)
xenTabPageLvmoHbaSummary.SuccessfullyCreatedSRs.Add(srDescriptor);
else
xenTabPageLvmoHbaSummary.FailedToCreateSRs.Add(srDescriptor);
}
示例12: Get
/// <summary>
/// HTTP GET file from HTTP action f, saving it to path (via a temporary file).
/// </summary>
/// <param name="action">Action on which to update the progress</param>
/// <param name="timeout">Whether to apply a timeout</param>
/// <param name="path">Path to save file to.</param>
/// <returns>Result of the task used to GET the file</returns>
public static String Get(AsyncAction action, bool timeout, string path, string hostname, Delegate f, params object[] p)
{
return Get(action, timeout, null, path, hostname, f, p);
}
示例13: ReconfigureManagement_
/// <summary>
/// Switch the host's management interface from its current setting over to the given PIF.
/// </summary>
private static void ReconfigureManagement_(AsyncAction action, PIF pif, int hi)
{
log.DebugFormat("Switching to PIF {0} {1} for management...", pif.Name, pif.uuid);
action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_MANAGEMENT_RECONFIGURING, pif.Name);
int mid = (hi + action.PercentComplete) / 2;
PIF p = (PIF)pif.Clone();
p.disallow_unplug = false;
p.ManagementPurpose = null;
p.SaveChanges(action.Session);
action.PercentComplete = mid;
action.RelatedTask = XenAPI.Host.async_management_reconfigure(action.Session, pif.opaque_ref);
action.PollToCompletion(mid, hi);
log.DebugFormat("Switched to PIF {0} {1} for management.", pif.Name, pif.uuid);
action.Description = string.Format(Messages.ACTION_CHANGE_NETWORKING_MANAGEMENT_RECONFIGURED, pif.Name);
}
示例14: SetSessionDetails
private void SetSessionDetails(AsyncAction action)
{
if (elevatedSession == null || string.IsNullOrEmpty(elevatedUsername) || string.IsNullOrEmpty(elevatedPassword))
return;
action.sudoUsername = elevatedUsername;
action.sudoPassword = elevatedPassword;
action.Session = elevatedSession;
}
示例15: ExtractApiCallList
private List<string> ExtractApiCallList(AsyncAction myAction)
{
RbacMethodList rbacMethods = new RbacMethodList();
RbacCollectorProxy.GetProxy(rbacMethods);
Session session = new Session(RbacCollectorProxy.GetProxy(rbacMethods), myAction.Connection);
myAction.RunExternal(session);
return rbacMethods.ConvertAll(c => c.Method.ToLower().Replace('.', '_').Replace("async_", ""));
}