UI 쓰레드를 새로 생성해서 폼을 Show 하고 Close 하는 소스코드
public partial class MainForm : Form
{
private static KeyboardForm keyboardForm = null;
private static void ThreadKeyboard()
{
keyboardForm = new KeyboardForm();
Application.Run(keyboardForm);
keyboardForm = null;
}
public static void OpenKeyboard()
{
if (keyboardForm != null) return;
Thread newThread = new Thread(new ThreadStart(ThreadKeyboard));
newThread.SetApartmentState(ApartmentState.STA);
newThread.Start();
}
public static void CloseKeyboard()
{
if (keyboardForm != null)
{
keyboardForm.BeginInvoke(new Action(() => { keyboardForm.Close(); }));
}
}
댓글 없음:
댓글 쓰기