mirror of
				https://gitee.com/csharpui/CPF.git
				synced 2025-11-01 00:46:56 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			834 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			834 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Diagnostics;
 | |
| using System.Text;
 | |
| using System.Threading;
 | |
| 
 | |
| namespace CPF.Windows
 | |
| {
 | |
|     public class WindowsSynchronizationContext : SynchronizationContext
 | |
|     {
 | |
|         public override void Post(SendOrPostCallback d, object state)
 | |
|         {
 | |
|             if (WindowImpl.Window != null)
 | |
|             {
 | |
|                 WindowImpl.Window.BeginInvoke(d, state);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 Debug.WriteLine("Window未初始化");
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public override void Send(SendOrPostCallback d, object state)
 | |
|         {
 | |
|             if (WindowImpl.Window != null)
 | |
|             {
 | |
|                 WindowImpl.Window.Invoke(d, state);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 d(state);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | 
