• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Threading.SynchronizationContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Threading.SynchronizationContext的典型用法代码示例。如果您正苦于以下问题:C# SynchronizationContext类的具体用法?C# SynchronizationContext怎么用?C# SynchronizationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SynchronizationContext类属于System.Threading命名空间,在下文中一共展示了SynchronizationContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
        }
开发者ID:bleis-tift,项目名称:gitextensions,代码行数:28,代码来源:ToolStripGitStatus.cs


示例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);
        }
开发者ID:sadstorm,项目名称:LoadTester112,代码行数:30,代码来源:Client.cs


示例3: MainForm

 public MainForm()
 {
     InitializeComponent();
     context = SynchronizationContext.Current;
     actions = new List<ActionEntry>();
     schedualeList = new Hashtable();
 }
开发者ID:Armanu,项目名称:Click_Looper,代码行数:7,代码来源:MainForm.cs


示例4: CloverExamplePOSForm

        public CloverExamplePOSForm()
        {
            //new CaptureLog();

            InitializeComponent();
            uiThread = WindowsFormsSynchronizationContext.Current;
        }
开发者ID:roninstar,项目名称:remote-pay-windows,代码行数:7,代码来源:CloverExamplePOSForm.cs


示例5: CommitInfo

        public CommitInfo()
        {
            _syncContext = SynchronizationContext.Current;

            InitializeComponent();
            Translate();
        }
开发者ID:robin521111,项目名称:gitextensions,代码行数:7,代码来源:CommitInfo.cs


示例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);
        }            
开发者ID:Jbtyson,项目名称:cis598,代码行数:31,代码来源:Form1.cs


示例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);
        }
开发者ID:bszafko,项目名称:gitextensions,代码行数:26,代码来源:RevisionGrid.cs


示例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;
        }
开发者ID:TwistedHope,项目名称:gitextensions,代码行数:28,代码来源:RevisionGrid.cs


示例9: CommChannel

        public CommChannel(Stream input, Stream output)
        {
            _input = new BinaryReader(input);
            _output = new BinaryWriter(output);
            _dispatcher = SynchronizationContext.Current;

        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:7,代码来源:CommChannel.cs


示例10: GitLogForm

 private GitLogForm()
 {
     ShowInTaskbar = true;
     syncContext = SynchronizationContext.Current;
     InitializeComponent();
     Translate();
 }
开发者ID:phiree,项目名称:gitextensions,代码行数:7,代码来源:GitLogForm.cs


示例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);
                }

            }
        }
开发者ID:Rhombulus,项目名称:WTalk,代码行数:25,代码来源:Conversation.cs


示例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());
        }
开发者ID:bartbart,项目名称:gitextensions,代码行数:35,代码来源:ToolStripGitStatus.cs


示例13: SynergyV4MainWindow

 public SynergyV4MainWindow()
 {
     InitializeComponent();
     syncContext = SynchronizationContext.Current;
     _sh.DbSavePending = false;
     this.DataContext = this;
 }
开发者ID:BBuchholz,项目名称:NineWorldsDeep,代码行数:7,代码来源:SynergyV4MainWindow.xaml.cs


示例14: DocumentModel

 public DocumentModel(string path)
 {
     if (path == null) throw new ArgumentNullException("path");
     FilePath = path;
     Size = new FileInfo(path).Length;
     syncContext = SynchronizationContext.Current;
 }
开发者ID:Amichai,项目名称:Prax,代码行数:7,代码来源:DocumentModel.cs


示例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();
        }
开发者ID:TroyBolton,项目名称:azure-mobile-services,代码行数:27,代码来源:MainViewModel.cs


示例16: RevisionGrid

        public RevisionGrid()
        {
            _syncContext = SynchronizationContext.Current;

            base.InitLayout();
            InitializeComponent();
            Translate();

            Message.DefaultCellStyle.Font = SystemFonts.DefaultFont;
            Date.DefaultCellStyle.Font = SystemFonts.DefaultFont;

            NormalFont = SystemFonts.DefaultFont;
            RefsFont = new Font(NormalFont, FontStyle.Bold);
            HeadFont = new Font(NormalFont, FontStyle.Bold);
            Loading.Paint += new PaintEventHandler(Loading_Paint);

            Revisions.CellPainting += RevisionsCellPainting;
            Revisions.KeyDown += RevisionsKeyDown;

            showRevisionGraphToolStripMenuItem.Checked = Settings.ShowRevisionGraph;
            showAuthorDateToolStripMenuItem.Checked = Settings.ShowAuthorDate;
            orderRevisionsByDateToolStripMenuItem.Checked = Settings.OrderRevisionByDate;
            showRelativeDateToolStripMenuItem.Checked = Settings.RelativeDate;
            drawNonrelativesGrayToolStripMenuItem.Checked = Settings.RevisionGraphDrawNonRelativesGray;

            BranchFilter = String.Empty;
            SetShowBranches();
            Filter = "";
            AllowGraphWithFilter = false;
            _quickSearchString = "";
            quickSearchTimer.Tick += QuickSearchTimerTick;

            Revisions.Loading += RevisionsLoading;
        }
开发者ID:AVarfolomeev,项目名称:gitextensions,代码行数:34,代码来源:RevisionGrid.cs


示例17: ThreadManager

 public ThreadManager([NotNull] SynchronizationContext synchronizationContext)
 {
     Should.NotBeNull(synchronizationContext, nameof(synchronizationContext));
     _synchronizationContext = synchronizationContext;
     synchronizationContext.Post(state => ((ThreadManager)state)._mainThreadId = ManagedThreadId, this);
     ServiceProvider.UiSynchronizationContext = synchronizationContext;
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:7,代码来源:ThreadManager.cs


示例18: VirtualListVewModel

        public VirtualListVewModel(SynchronizationContext bindingContext, DataService service)
        {
            _virtualRequest = new BehaviorSubject<VirtualRequest>(new VirtualRequest(0,10));

            Items = new BindingList<Poco>();

            var sharedDataSource = service
                .DataStream
                .Do(x => Trace.WriteLine($"Service -> {x}"))
                .ToObservableChangeSet()
                .Publish();

            var binding = sharedDataSource
                          .Virtualise(_virtualRequest)
                          .ObserveOn(bindingContext)
                          .Bind(Items)
                          .Subscribe();
            
            //the problem was because Virtualise should fire a noticiation if count changes, but it does not [BUG]
            //Therefore take the total count from the underlying data NB: Count is DD.Count() not Observable.Count()
            Count = sharedDataSource.Count().DistinctUntilChanged();

            Count.Subscribe(x => Trace.WriteLine($"Count = {x}"));

            var connection = sharedDataSource.Connect();
            _disposables = new CompositeDisposable(binding, connection);
        }
开发者ID:RolandPheasant,项目名称:Test-Dynamic-Data,代码行数:27,代码来源:VirtualListVewModel.cs


示例19: EnsureContext

 private static void EnsureContext(SynchronizationContext context)
 {
     if (Current != context)
     {
         SetSynchronizationContext(context);
     }
 }
开发者ID:tianzhaodong,项目名称:uwp_AiJianShu,代码行数:7,代码来源:ExceptionHandlingSynchronizationContext.cs


示例20: FormBrowse

        public FormBrowse(string filter)
        {
            syncContext = SynchronizationContext.Current;

            InitializeComponent();
            Translate();

            if (Settings.ShowGitStatusInBrowseToolbar)
            {
                var status = new ToolStripGitStatus
                                 {
                                     ImageTransparentColor = System.Drawing.Color.Magenta
                                 };
                status.Click += StatusClick;
                ToolStrip.Items.Insert(1, status);
            }

            RevisionGrid.SelectionChanged += RevisionGridSelectionChanged;
            DiffText.ExtraDiffArgumentsChanged += DiffTextExtraDiffArgumentsChanged;
            SetFilter(filter);

            GitTree.ImageList = new ImageList();
            GitTree.ImageList.Images.Add(Properties.Resources._21); //File
            GitTree.ImageList.Images.Add(Properties.Resources._40); //Folder
            GitTree.ImageList.Images.Add(Properties.Resources._39); //Submodule
        }
开发者ID:RodH257,项目名称:gitextensions,代码行数:26,代码来源:FormBrowse.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Threading.Task类代码示例发布时间:2022-05-26
下一篇:
C# Threading.StackCrawlMark类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap