■ AppDomain 클래스 : 동일 프로세스에서 멀티 WPF 애플리케이션 실행하기
------------------------------------------------------------------------------------------------------------------------
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300" Title="AppDomain 클래스 : 동일 프로세스에서 멀티 WPF 애플리케이션 실행하기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <ContentControl HorizontalAlignment="Center" VerticalAlignment="Center" Content="{Binding DomainName}" /> </Grid> </Window>
|
▶ MainWindow.xaml.cs
using System; using System.Windows;
namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent();
DataContext = new { DomainName = AppDomain.CurrentDomain.FriendlyName }; }
#endregion } }
|
▶ Program.cs
using System; using System.Threading; using System.Windows;
namespace TestProject { /// <summary> /// 프로그램 /// </summary> class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private
#region 프로그램 시작하기 - Main()
/// <summary> /// 프로그램 시작하기 /// </summary> [STAThread()] [LoaderOptimization(LoaderOptimization.MultiDomainHost)] private static void Main() { AppDomain appDomain1 = AppDomain.CreateDomain("첫번째 전용 도메인"); AppDomain appDoamin2 = AppDomain.CreateDomain("두번째 전용 도메인");
CrossAppDomainDelegate action = () => {
Thread thread = new Thread ( () => {
Application application = new Application();
application.MainWindow = new MainWindow();
application.MainWindow.Show();
application.Run(); } );
thread.SetApartmentState(ApartmentState.STA);
thread.Start(); };
appDomain1.DoCallBack(action); appDoamin2.DoCallBack(action); }
#endregion } }
|
------------------------------------------------------------------------------------------------------------------------
'C# > WPF' 카테고리의 다른 글
[C#/WPF] HwndSource 클래스 : AddHook 메소드를 사용해 윈도우 이벤트 가로채기 (0) | 2019.06.02 |
---|---|
[C#/WPF] Dispatcher 클래스 : UnhandledException 이벤트를 사용해 예외 처리하기 (0) | 2019.06.02 |
[C#/WPF] SystemColors 클래스 : 시스템 색상 표시하기 (0) | 2019.06.02 |
[C#/WPF] Dispatcher 클래스 : Invoke 메소드를 사용해 UI 업데이트 하기 (0) | 2019.05.30 |
[C#/WPF] 메모리 손실이 없는 비트맵 소스 구하기 (0) | 2019.05.30 |
[C#/WPF] AppDomain 클래스 : 동일 프로세스에서 멀티 WPF 애플리케이션 실행하기 (0) | 2019.05.30 |
[C#/WPF] 다중 UI 스레드 윈도우 사용하기 (0) | 2019.05.30 |
[C#/WPF] ScrollViewer 클래스 : 마우스를 사용해 스크롤하기 (0) | 2019.05.28 |
[C#/WPF] BitmapImage 클래스 : 웹에서 비트맵 이미지 구하기 (0) | 2019.05.27 |
[C#/WPF] BitmapImage 클래스 : 비트맵 이미지 구하기 (0) | 2019.05.27 |
[C#/WPF] ScrollViewer 클래스 : IsDeferredScrollingEnabled 속성을 사용해 스크롤 성능 높이기 (0) | 2019.05.27 |
댓글을 달아 주세요