当前位置: 首页>>代码示例>>C#>>正文


C# SynchronizationContext.Send方法代码示例

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


在下文中一共展示了SynchronizationContext.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunComparisonProcess

        public void RunComparisonProcess(object param)
        {
            try
            {
                context = (SynchronizationContext)param;

                SetProgressPercentage(0);

                Logger.LogInfo("Starting comparison process...");

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                EssayComparisonManager.Instance.IsComparisonCompete = false;
                EssayComparisonManager.Instance.EssayComparisonPercentage = Compare();

                stopwatch.Stop();

                var ts = stopwatch.Elapsed;
                var elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

                Logger.LogInfo("Comparison completed. Elapsed time: " + elapsedTime);

                SetProgressPercentage(100);
                context.Send(OnWorkCompleted, elapsedTime);
            }
            catch (Exception ex)
            {
                Logger.LogError("Here is some problem..." + ex);
            }
        }
开发者ID:ShallDen,项目名称:Referring,代码行数:31,代码来源:EssayComparisonProcess.cs

示例2: RunReferrengProcess

        public void RunReferrengProcess(object param)
        {
            try
            {
                context = (SynchronizationContext)param;
                UsePercentage = true;

                SetProgressPercentage(0);

                Logger.LogInfo("Starting referring process...");

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                ReferringManager.Instance.IsReferringRunning = true;

                Logger.LogInfo("Getting sentence list.");
                sentenceList = ReferringManager.Instance.OriginalText.ClearUnnecessarySymbolsInText()
                    .DivideTextToSentences()
                    .ClearWhiteSpacesInList()
                    .RemoveEmptyItemsInList()
                    .ToLower();

                Logger.LogInfo("Getting word list.");
                wordList = ReferringManager.Instance.OriginalText.ClearUnnecessarySymbolsInText()
                    .DivideTextToWords()
                    .RemoveEmptyItemsInList()
                    .ToLower();

                Logger.LogInfo(string.Format("Text contains {0} sentences and {1} words.", sentenceList.Count, wordList.Count));

                Logger.LogInfo("Calculate word weights.");
                CalculateWordWeights();

                Logger.LogInfo("Calculating sentence weights.");
                CalculateSentenceWeights();

                Logger.LogInfo("Calculating required sentence count.");
                int sentenceCount = goodSentenceList.Count;
                int requiredSentenceCount = (int)(sentenceCount * ReferringManager.Instance.ReferringCoefficient);
                Logger.LogInfo(string.Format("Required sentences: {0}.", requiredSentenceCount));

                ReferringManager.Instance.OriginalTextSentenceCount = sentenceCount;
                ReferringManager.Instance.ReferredTextSentenceCount = requiredSentenceCount;

                Logger.LogInfo("Taking required sentences with biggest weight.");
                var requiredSentences = goodSentenceList.OrderByDescending(c => c.Weight).Take(requiredSentenceCount).ToList();

                Logger.LogInfo("Building the essay.");
                string essay = EssayBuilder.BuildEssay(requiredSentences, goodSentenceList);

                ReferringManager.Instance.ReferredText = essay;
                ReferringManager.Instance.IsReferringCompete = true;
                ReferringManager.Instance.OrderedWordList = goodWordList.TransformPOSToRussian().OrderByDescending(c => c.Weight).ToList();

                //order words and weights by weight only for comfortable view
                var showGoodWordList = ReferringManager.Instance.OrderedWordList;
                var showGoodSentenceList = goodSentenceList.OrderByDescending(c => c.Weight).ToList();

                stopwatch.Stop();

                var ts = stopwatch.Elapsed;
                var elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

                Logger.LogInfo("Referring completed. Elapsed time: " + elapsedTime);

                SetProgressPercentage(100);
                context.Send(OnWorkCompleted, elapsedTime);
            }
            catch (Exception ex)
            {
                Logger.LogError("Here is some problem..." + ex);

                ReferringManager.Instance.IsReferringRunning = false;
            }
        }
开发者ID:ShallDen,项目名称:Referring,代码行数:76,代码来源:ReferringProcess.cs

示例3: GetRender

        public RenderBuffer GetRender(string url, SynchronizationContext synchronizationContext)
        {
            WebView webView = null;
            synchronizationContext.Send((object state) => webView = WebCore.CreateWebView(1024, 768), null);

            synchronizationContext.Send(((object state) => webView.LoadURL(url)), null);

            while (webView.IsLoadingPage)
                SleepAndUpdateCore(synchronizationContext);

            webView.RequestScrollData();
            webView.ScrollDataReceived += OnScrollDataReceived;

            while (!_finishedScrollDataReceived)
                SleepAndUpdateCore(synchronizationContext);

            var width = _scrollData.ContentWidth > MaxWidth ? MaxWidth : _scrollData.ContentWidth;
            var height = _scrollData.ContentHeight > MaxHeight ? MaxHeight : _scrollData.ContentHeight;
            webView.Resize(width, height);

            while (webView.IsResizing)
                SleepAndUpdateCore(synchronizationContext);

            return webView.Render();
        }
开发者ID:meze,项目名称:betteamsbattle,代码行数:25,代码来源:ScreenshotRenderService.cs

示例4: KinectReplay

		public KinectReplay(string fileName)
		{
            Started = false;
			stream = File.OpenRead(fileName);
			reader = new BinaryReader(stream);

			synchronizationContext = SynchronizationContext.Current;

			Options = (KinectRecordOptions)reader.ReadInt32();
            //var paramsArrayLength = reader.ReadInt32();
            //var colorToDepthRelationalParameters = reader.ReadBytes(paramsArrayLength);
            //CoordinateMapper = new CoordinateMapper(colorToDepthRelationalParameters);

			if ((Options & KinectRecordOptions.Frames) != 0)
			{
				framesReplay = new ReplayAllFramesSystem();
				framesReplay.AddFrames(reader);
				framesReplay.ReplayFinished += () => synchronizationContext.Send(state => ReplayFinished.Raise(),null);
			}
			if ((Options & KinectRecordOptions.Audio) != 0)
			{
				var audioFilePath = Path.ChangeExtension(fileName, ".wav");
				if (File.Exists(audioFilePath))
					AudioFilePath = audioFilePath;
			}
            
		}
开发者ID:darekf77,项目名称:Kinect.Replay,代码行数:27,代码来源:KinectReplay.cs

示例5: Main

 /// <summary>
 /// Entry point of the application.
 /// </summary>
 /// <param name="args">An array of command line arguments.</param>
 public static void Main(string[] args)
 {
     try {
         var context = new SynchronizationContext();
         context.Send((x) => TaskMain().Wait(), null);
     } catch (AggregateException E) {
         throw E.InnerException;
     }
 }
开发者ID:Tamschi,项目名称:FacePuncher,代码行数:13,代码来源:Program.cs

示例6: CloverExamplePOSForm

        public CloverExamplePOSForm()
        {
            InitializeComponent();
            uiThread = WindowsFormsSynchronizationContext.Current;

            uiThread.Send(delegate (object state)
            {
                new StartupForm(this).Show();
            }, null);
        }
开发者ID:clover,项目名称:remote-pay-windows,代码行数:10,代码来源:CloverExamplePOSForm.cs

示例7: SetTrayVisibleIndeterminent

 internal static void SetTrayVisibleIndeterminent(this Page containerPage, String message, SynchronizationContext syncContext)
 {
     syncContext.Send(callback =>
     {
         SystemTray.SetIsVisible(containerPage, true);
         SystemTray.SetOpacity(containerPage, 0.5);
         var indicator = new ProgressIndicator {Text = message, IsVisible = true, IsIndeterminate = true};
         SystemTray.SetProgressIndicator(containerPage, indicator);
     }, null);
 }
开发者ID:touhid91,项目名称:MovieGeek,代码行数:10,代码来源:SystemTrayHelper.cs

示例8: DoFlash

		private static void DoFlash(IVectorGraphic graphic, SynchronizationContext context)
		{
			context.Send(delegate
			             	{
			             		if (graphic.ImageViewer != null && graphic.ImageViewer.DesktopWindow != null)
			             		{
			             			graphic.Color = _invalidColor;
			             			graphic.Draw();
			             		}
			             	}, null);
			Thread.Sleep(_flashDelay);
			context.Send(delegate
			             	{
			             		if (graphic.ImageViewer != null && graphic.ImageViewer.DesktopWindow != null)
			             		{
			             			graphic.Color = _normalColor;
			             			graphic.Draw();
			             		}
			             	}, null);
		}
开发者ID:nhannd,项目名称:Xian,代码行数:20,代码来源:InteractiveShutterGraphicBuilders.cs

示例9: DisposeWithViewModelTestControl

        public DisposeWithViewModelTestControl()
        {
            InitializeComponent();
            syncContext = SynchronizationContext.Current;

            placeholder.Disposed += delegate
                                        {
                                            syncContext.Send(state => UpdateText(), null);
                                        };
            UpdateText();
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:11,代码来源:DisposeWithViewModelTestControl.xaml.cs

示例10: FlowController

 internal static async Task FlowController(this FrameworkElement fx, IEnumerable<Movie> movies, SynchronizationContext syncContext)
 {
     while (true)
     {
         await Task.Delay(TimeSpan.FromSeconds(Rand(7, 12))).ContinueWith(task => syncContext.Send(callback =>
         {
             var storyBd = fx.FindName("Update") as Storyboard;
             if (storyBd != null)
                 storyBd.Begin();
             fx.DataContext = movies.Shuffle();
         }, null));
     }
 }
开发者ID:touhid91,项目名称:MovieGeek,代码行数:13,代码来源:ShuffleHelper.cs

示例11: AddNotificationsSource

        public static void AddNotificationsSource(WordList list)
        {
            // REDO: for multiple sources of notifications
            wordList = list;

            if (notificationsTimer == null)
            {
                notificationsTimer = new System.Timers.Timer();
                notificationsTimer.Interval = 6000; //1000*60;
                notificationsTimer.AutoReset = false;
                notificationsTimer.Elapsed += notificationsTimer_Elapsed;
                notificationsTimer.Start();

                uiContext = SynchronizationContext.Current;

                uiContext.Send(ShowNotification, "test");
            }
        }
开发者ID:rov3rPL,项目名称:FishNoty,代码行数:18,代码来源:StaticController.cs

示例12: P2PService

        /// <summary>
        /// Создает экземпляр сервиса для функционирования UDP hole punching. Без логирования.
        /// </summary>
        public P2PService(int port, bool usingIPv6)
        {
            disposed = false;
              requests = new List<RequestPair>();
              clientsEndPoints = new Dictionary<string, ClientDescription>();
              connectingClients = new HashSet<string>();

              NetPeerConfiguration config = new NetPeerConfiguration(AsyncPeer.NetConfigString);
              config.MaximumConnections = 100;
              config.Port = port;

              if (usingIPv6)
            config.LocalAddress = IPAddress.IPv6Any;

              syncContext = new EngineSyncContext();

              server = new NetServer(config);
              syncContext.Send(s => ((NetServer)s).RegisterReceivedCallback(ReceivedCallback), server);
              server.Start();
        }
开发者ID:Nowsoud,项目名称:TCPChat,代码行数:23,代码来源:P2PService.cs

示例13: Start

        public void Start()
        {
            context = SynchronizationContext.Current;

            CancellationToken token = cancellationTokenSource.Token;

            Task.Factory.StartNew(() =>
            {
                foreach (ReplaySkeletonFrame frame in frames)
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(frame.TimeStamp));

                    if (token.IsCancellationRequested)
                        return;

                    ReplaySkeletonFrame closure = frame;
                    context.Send(state =>
                                    {
                                        if (SkeletonFrameReady != null)
                                            SkeletonFrameReady(this, new ReplaySkeletonFrameReadyEventArgs {SkeletonFrame = closure});
                                    }, null);
                }
            }, token);
        }
开发者ID:nhippenmeyer,项目名称:CS247,代码行数:24,代码来源:SkeletonReplay.cs

示例14: SetTrayCollapsed

 internal static Task SetTrayCollapsed(this Page containerPage, SynchronizationContext syncContext)
 {
     Thread.Sleep(2000);
     syncContext.Send(callback => SystemTray.SetIsVisible(containerPage, false), null);
     return null;
 }
开发者ID:touhid91,项目名称:MovieGeek,代码行数:6,代码来源:SystemTrayHelper.cs

示例15: __InitPreviewForUris

        static void __InitPreviewForUris(
            List<PathAndDrawable> list,
            CancellationToken ct,
            SynchronizationContext sync,
            Android.Content.Res.Resources res,
            Action callback)
        {
            for (int i = 0; i < list.Count && !ct.IsCancellationRequested; i++)
            {
                var uad = list[i];

                if (uad.path.IsImage())
                {
                    try
                    {
                        uad.drawable = GetResized(Drawable.CreateFromPath(uad.path), res);
                    }
                    catch (Exception ex)
                    {
                        ex.Handle(true);
                    }
                }

                list[i] = uad;

                if (!ct.IsCancellationRequested && callback != null && sync != null)
                    sync.Send(new SendOrPostCallback(state => callback()), null);
            }
        }
开发者ID:fubar-coder,项目名称:cryptrans,代码行数:29,代码来源:Preview.cs


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