本文整理汇总了C#中System.Threading.SynchronizationContext类的典型用法代码示例。如果您正苦于以下问题:C# SynchronizationContext类的具体用法?C# SynchronizationContext怎么用?C# SynchronizationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SynchronizationContext类属于System.Threading命名空间,在下文中一共展示了SynchronizationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToolStripGitStatus
public ToolStripGitStatus()
{
syncContext = SynchronizationContext.Current;
gitGetUnstagedCommand.Exited += new EventHandler(delegate(object o, EventArgs ea)
{
syncContext.Post(_ => onData(), null);
});
InitializeComponent();
Settings.WorkingDirChanged += new Settings.WorkingDirChangedHandler(Settings_WorkingDirChanged);
// Setup a file watcher to detect changes to our files, or the .git repo files. When they
// change, we'll update our status.
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
watcher.Created += new FileSystemEventHandler(watcher_Changed);
watcher.Deleted += new FileSystemEventHandler(watcher_Changed);
watcher.Error += new ErrorEventHandler(watcher_Error);
watcher.IncludeSubdirectories = true;
try
{
watcher.Path = Settings.WorkingDir;
watcher.EnableRaisingEvents = true;
}
catch { }
update();
}
示例2: Client
public Client(int id, Config cfg, SynchronizationContext ctx)
{
ClientStatisticsGatherer = new ClientStatisticsGatherer();
_ctx = ctx;
_id = id;
Data = new TestData(this);
IsStopped = false;
_log = LogManager.GetLogger("Client_" + _id);
_log.Debug("Client created");
Configure(cfg);
if (String.IsNullOrEmpty(_login))
{
const string err = "Login command is not specified!!! Can't do any test.";
_log.Error(err);
throw new Exception(err);
}
_ajaxHelper = new AjaxHelper(new AjaxConn(_login, cfg.ServerIp, cfg.AjaxPort, _ctx));
_webSock = new WebSockConn(_login, cfg.ServerIp, cfg.WsPort, ctx);
_webSock.CcsStateChanged += WsOnCcsStateChanged;
_webSock.InitializationFinished += () => _testMng.GetTest<LoginTest>().OnClientInitialized();
_testMng.SetEnv(_login, _ajaxHelper.AjaxConn, _webSock);
}
示例3: MainForm
public MainForm()
{
InitializeComponent();
context = SynchronizationContext.Current;
actions = new List<ActionEntry>();
schedualeList = new Hashtable();
}
示例4: CloverExamplePOSForm
public CloverExamplePOSForm()
{
//new CaptureLog();
InitializeComponent();
uiThread = WindowsFormsSynchronizationContext.Current;
}
示例5: CommitInfo
public CommitInfo()
{
_syncContext = SynchronizationContext.Current;
InitializeComponent();
Translate();
}
示例6: OnLoad
protected override void OnLoad(EventArgs e)
{
if(InputDevice.DeviceCount == 0)
{
MessageBox.Show("No MIDI input devices available.", "Error!",
MessageBoxButtons.OK, MessageBoxIcon.Stop);
Close();
}
else
{
try
{
context = SynchronizationContext.Current;
inDevice = new InputDevice(0);
inDevice.ChannelMessageReceived += HandleChannelMessageReceived;
inDevice.SysCommonMessageReceived += HandleSysCommonMessageReceived;
inDevice.SysExMessageReceived += HandleSysExMessageReceived;
inDevice.SysRealtimeMessageReceived += HandleSysRealtimeMessageReceived;
inDevice.Error += new EventHandler<ErrorEventArgs>(inDevice_Error);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error!",
MessageBoxButtons.OK, MessageBoxIcon.Stop);
Close();
}
}
base.OnLoad(e);
}
示例7: RevisionGrid
public RevisionGrid()
{
syncContext = SynchronizationContext.Current;
base.InitLayout();
InitializeComponent();
Revisions.Columns[0].Width = 40;
NormalFont = Revisions.Font;
HeadFont = new Font(NormalFont, FontStyle.Bold);
//RefreshRevisions();
Revisions.CellPainting += new DataGridViewCellPaintingEventHandler(Revisions_CellPainting);
Revisions.SizeChanged += new EventHandler(Revisions_SizeChanged);
Revisions.KeyDown += new KeyEventHandler(Revisions_KeyDown);
showRevisionGraphToolStripMenuItem.Checked = Settings.ShowRevisionGraph;
showAuthorDateToolStripMenuItem.Checked = Settings.ShowAuthorDate;
orderRevisionsByDateToolStripMenuItem.Checked = Settings.OrderRevisionByDate;
showRelativeDateToolStripMenuItem.Checked = Settings.RelativeDate;
SetShowBranches();
filter = "";
quickSearchString = "";
quickSearchTimer.Tick += new EventHandler(quickSearchTimer_Tick);
}
示例8: RevisionGrid
public RevisionGrid()
{
_syncContext = SynchronizationContext.Current;
base.InitLayout();
InitializeComponent();
Translate();
NormalFont = Revisions.Font;
HeadFont = new Font(NormalFont, FontStyle.Underline);
RefsFont = new Font(NormalFont, FontStyle.Bold);
Revisions.CellPainting += RevisionsCellPainting;
Revisions.KeyDown += RevisionsKeyDown;
showRevisionGraphToolStripMenuItem.Checked = Settings.ShowRevisionGraph;
showAuthorDateToolStripMenuItem.Checked = Settings.ShowAuthorDate;
orderRevisionsByDateToolStripMenuItem.Checked = Settings.OrderRevisionByDate;
showRelativeDateToolStripMenuItem.Checked = Settings.RelativeDate;
BranchFilter = String.Empty;
SetShowBranches();
Filter = "";
_quickSearchString = "";
quickSearchTimer.Tick += QuickSearchTimerTick;
Revisions.Loading += RevisionsLoading;
}
示例9: CommChannel
public CommChannel(Stream input, Stream output)
{
_input = new BinaryReader(input);
_output = new BinaryWriter(output);
_dispatcher = SynchronizationContext.Current;
}
示例10: GitLogForm
private GitLogForm()
{
ShowInTaskbar = true;
syncContext = SynchronizationContext.Current;
InitializeComponent();
Translate();
}
示例11: Conversation
internal Conversation(ConversationState conversationState)
{
_synchronizationContext = Client.CurrentSynchronizationContext;
_conversation = conversationState.conversation;
if (_conversation.read_state.Count > 0)
ReadState = _conversation.read_state.Last(c=>c.latest_read_timestamp > 0).latest_read_timestamp.FromUnixTime();
if (_conversation.self_conversation_state.self_read_state != null)
SelfReadState = _conversation.self_conversation_state.self_read_state.latest_read_timestamp.FromUnixTime();
Participants = _conversation.participant_data.ToDictionary(c=>c.id.chat_id, c => new Participant(c));
MessagesHistory = new ObservableCollection<Message>();
foreach(var cse in conversationState.events.Where(c=>c.chat_message != null))
{
messagesIds.Add(cse.event_id, cse.timestamp);
if (_lastMessage != null && _lastMessage.SenderId == cse.sender_id.gaia_id)
_lastMessage.AddContent(cse);
else
{
_lastMessage = new Message(cse);
MessagesHistory.Add(_lastMessage);
}
}
}
示例12: ToolStripGitStatus
public ToolStripGitStatus()
{
syncContext = SynchronizationContext.Current;
gitGetUnstagedCommand.Exited += (o, ea) => syncContext.Post(_ => onData(), null);
InitializeComponent();
CommitTranslatedString = "Commit";
Settings.WorkingDirChanged += (_, newDir, newGitDir) => TryStartWatchingChanges(newDir, newGitDir);
GitUICommands.Instance.PreCheckoutBranch += GitUICommands_PreCheckout;
GitUICommands.Instance.PreCheckoutRevision += GitUICommands_PreCheckout;
GitUICommands.Instance.PostCheckoutBranch += GitUICommands_PostCheckout;
GitUICommands.Instance.PostCheckoutRevision += GitUICommands_PostCheckout;
// Setup a file watcher to detect changes to our files. When they
// change, we'll update our status.
watcher.Changed += watcher_Changed;
watcher.Created += watcher_Changed;
watcher.Deleted += watcher_Changed;
watcher.Error += watcher_Error;
watcher.IncludeSubdirectories = true;
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
// Setup a file watcher to detect changes to the .git repo files. When they
// change, we'll update our status.
gitDirWatcher.Changed += gitWatcher_Changed;
gitDirWatcher.Created += gitWatcher_Changed;
gitDirWatcher.Deleted += gitWatcher_Changed;
gitDirWatcher.Error += watcher_Error;
gitDirWatcher.IncludeSubdirectories = true;
gitDirWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
TryStartWatchingChanges(Settings.WorkingDir, Settings.Module.GetGitDirectory());
}
示例13: SynergyV4MainWindow
public SynergyV4MainWindow()
{
InitializeComponent();
syncContext = SynchronizationContext.Current;
_sh.DbSavePending = false;
this.DataContext = this;
}
示例14: DocumentModel
public DocumentModel(string path)
{
if (path == null) throw new ArgumentNullException("path");
FilePath = path;
Size = new FileInfo(path).Length;
syncContext = SynchronizationContext.Current;
}
示例15: MainViewModel
public MainViewModel(IPopupService popupService, SynchronizationContext synchonizationContext)
{
var client = new MobileServiceClient(
_mobileServiceUrl,
_mobileServiceKey);
_liveAuthClient = new LiveAuthClient(_mobileServiceUrl);
// Apply a ServiceFilter to the mobile client to help with our busy indication
_mobileServiceClient = client.WithFilter(new DotoServiceFilter(
busy =>
{
IsBusy = busy;
}));
_popupService = popupService;
_synchronizationContext = synchonizationContext;
_invitesTable = _mobileServiceClient.GetTable<Invite>();
_itemsTable = _mobileServiceClient.GetTable<Item>();
_profilesTable = _mobileServiceClient.GetTable<Profile>();
_listMembersTable = _mobileServiceClient.GetTable<ListMembership>();
_devicesTable = _mobileServiceClient.GetTable<Device>();
_settingsTable = _mobileServiceClient.GetTable<Setting>();
SetupCommands();
LoadSettings();
}