本文整理汇总了C#中MethodInvoker类的典型用法代码示例。如果您正苦于以下问题:C# MethodInvoker类的具体用法?C# MethodInvoker怎么用?C# MethodInvoker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodInvoker类属于命名空间,在下文中一共展示了MethodInvoker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeterMineCall
private void DeterMineCall(MethodInvoker method)
{
if (InvokeRequired && !this.IsDisposed)
Invoke(method);
else
method();
}
示例2: StartTry
public static Thread StartTry(MethodInvoker code, ErrorHandler on_error = null, MethodInvoker on_finally = null, bool background = true)
{
Thread t = new Thread(
() => {
try
{
code.Invoke();
}
catch (ThreadAbortException e)
{
Thread.ResetAbort();
}
catch (Exception e)
{
if (on_error != null)
on_error.Invoke(e);
else
Message.Error(e);
}
finally
{
on_finally?.Invoke();
}
}
);
t.IsBackground = background;
t.Start();
return t;
}
示例3: UpdateState
private void UpdateState()
{
MethodInvoker invoker = new MethodInvoker(delegate()
{
if ((File.GetAttributes(m_originalSolutionFullPath) & FileAttributes.ReadOnly) != 0)
{
m_labelState.ForeColor = Color.Red;
m_labelState.Text = "ReadOnly";
m_labelStateDescription.Visible = true;
m_buttonYes.Enabled = false;
}
else
{
m_labelState.ForeColor = Color.Black;
m_labelState.Text = "Writable";
m_labelStateDescription.Visible = false;
m_buttonYes.Enabled = true;
}
});
if (m_labelState.InvokeRequired)
{
this.Invoke(invoker);
}
else
{
invoker.Invoke();
}
}
示例4: CheckAvailable
/// <summary>
/// Check to see if an update to the application is available.
/// </summary>
/// <param name="available">A <see cref="MethodInvoker"/> delegate which is called if an update is available.</param>
internal static void CheckAvailable(MethodInvoker available)
{
ThreadPool.QueueUserWorkItem(delegate
{
CachedWebClient checkUpdate = CachedWebClient.GetInstance();
string versionInfo = null;
try
{
versionInfo = checkUpdate.DownloadString(new Uri(BaseUrl + Application.ProductVersion), CacheHours);
}
catch (WebException)
{
// Temporary problem downloading the information, try again later
return;
}
Settings.LastCheckForUpdates = DateTime.Now;
if (!string.IsNullOrEmpty(versionInfo))
{
versionInfo = versionInfo.Split(new string[] { "\r\n" }, StringSplitOptions.None)[0];
if (string.Compare(versionInfo, Application.ProductVersion, StringComparison.Ordinal) > 0)
{
// There is a new version available
available();
}
}
return;
});
}
示例5: FTeams
internal FTeams(ref Common.Interface newCommon)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
CommonCode = newCommon;
Trace.WriteLine("FTeams: Creating");
EnableMeInvoker = new MethodInvoker(this.enableMe);
PopulateTeamsDropDownThreadInvoker +=
new MethodInvoker(populateTeamsDropDownThread);
try
{
height = this.Size.Height;
width = this.Size.Width;
}
catch(Exception exc)
{
Trace.WriteLine("FTeams: Exception during creation:" + exc.ToString());
throw;
}
finally
{
Trace.WriteLine("FTeams: Created.");
}
}
示例6: UIBlockingInvoke
/// <summary>
/// Runs a MethodInvoker delegate on the UI thread from whichever thread we are currently calling from and BLOCKS until it is complete
/// </summary>
/// <param name="ivk"></param>
public void UIBlockingInvoke(MethodInvoker ivk)
{
System.Threading.ManualResetEvent UIAsyncComplete = new System.Threading.ManualResetEvent(false);
UIAsyncComplete.Reset();
if (this.InvokeRequired)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
try
{
ivk();
}
finally
{
UIAsyncComplete.Set();
}
}));
UIAsyncComplete.WaitOne();
}
else
{
ivk();
}
}
示例7: add_Button
public static Button add_Button(this Control control, string text, int top, int left, int height, int width, MethodInvoker onClick)
{
return control.invokeOnThread(
() =>
{
var button = new Button {Text = text};
if (top > -1)
button.Top = top;
if (left > -1)
button.Left = left;
if (width == -1 && height == -1)
button.AutoSize = true;
else
{
if (width > -1)
button.Width = width;
if (height > -1)
button.Height = height;
}
button.onClick(onClick);
/*if (onClick != null)
button.Click += (sender, e) => onClick();*/
control.Controls.Add(button);
return button;
});
}
示例8: Page_Load
/// <summary>
/// Load default value to control and other initialize.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MethodInvoker runHitCount = new MethodInvoker(UpdateHitCount);
runHitCount.BeginInvoke(CurrentWeb, HttpContext.Current, null, null);
//dvBG.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
//dvHitCount.InnerText = HitCountNumber.ToString();
//dvBGDay.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
//dvHitCountDay.InnerText = DayHitCountNumber.ToString();
//dvBGNow.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
//dvHitCountNow.InnerText = CurrentHitCountNumber.ToString();
//dvBGWeek.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
//dvHitCountWeek.InnerText = WeekHitCountNumber.ToString();
//dvBGMonth.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
//dvHitCountMonth.InnerText = MonthHitCountNumber.ToString();
//dvBGYesterday.Attributes.Add("style", "background-image: url('" + DocLibUrl + "/statistic.jpg'); width: 118px; height: 35px;");
//dvHitCountYesterday.InnerText = YesterdayHitCountNumber.ToString();
tdAll.InnerText = HitCountNumber.ToString();
tdToday.InnerText = DayHitCountNumber.ToString();
lblCurrent.Text = "<span id='spCurrent'>" + CurrentHitCountNumber.ToString() + "</span>";
tdThisWeek.InnerText = WeekHitCountNumber.ToString();
tdThisMonth.InnerText = MonthHitCountNumber.ToString();
tdYesterday.InnerText = YesterdayHitCountNumber.ToString();
}
}
示例9: FloodFillDrawer
public FloodFillDrawer(PolygonsContainer data, MethodInvoker ImageRefresher = null)
{
this.ImageRefresher = ImageRefresher;
this.data = data;
InitializeFloodFillStrategies();
floodFillerStrategy = strategiesList[0];
}
示例10: InvokeIfRequired
private void InvokeIfRequired(MethodInvoker _delegate)
{
if (this.InvokeRequired)
this.BeginInvoke(_delegate);
else
_delegate();
}
示例11: MarshalToForm
private void MarshalToForm(MethodInvoker code)
{
if (m_form.InvokeRequired)
m_form.BeginInvoke(code);
else
code();
}
示例12: InvokeIfRequired
private static void InvokeIfRequired(ISynchronizeInvoke control, MethodInvoker action)
{
if (control.InvokeRequired)
control.Invoke(action, new object[0]);
else
action();
}
示例13: ShortcutAction
public ShortcutAction(Keys k, bool ctrl, bool editorMustBeFocused, MethodInvoker func)
{
Key = k;
Ctrl = ctrl;
EditorMustBeFocused = editorMustBeFocused;
fMethodInvoker = func;
}
示例14: InvokeIfRequired
public static void InvokeIfRequired(this ISynchronizeInvoke control, MethodInvoker action)
{
if (control.InvokeRequired)
control.Invoke(action, null);
else
action();
}
示例15: Execute
public override void Execute()
{
string msg = "";
if (AppContext.IsAppInitializing && AppContext.IsGetSignalList && AppContext.SignalDatas.Count > 0)
{
signals = new Signal[AppContext.SignalDatas.Count];
AppContext.SignalDatas.CopyTo(signals);
MethodInvoker mi = new MethodInvoker(InitPriceList);
priceListView.Invoke(mi);
mi = new MethodInvoker(InitSignalList);
signalListView.Invoke(mi);
mi = new MethodInvoker(InitStatList);
statListView.Invoke(mi);
}
else if (AppContext.IsAppInitializing && AppContext.IsGetSymbolPrices && AppContext.SymbolPrices.Count > 0)
{
MethodInvoker mi = new MethodInvoker(InitPriceList);
priceListView.Invoke(mi);
AppContext.IsStatListInitialized = true;
AppContext.IsSignalListInitialized = true;
}
else
{
if (AppSetting.STATUS == AppSetting.TEST_ACCOUNT) // || AppSetting.STATUS == AppSetting.ADMIN_ACCOUNT
{
msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "2" });
}
else
{
msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "0" });
}
Send(msg);
}
}