Solved with desktops
1) describe WinApi wrappers
[StructLayout(Sequental, Unicode)]
public struct SECURITY_ATTRIBUTES{ public Int32 nLength, SecurityDescriptor, bInheritHandle; }
describe referenses to WinApi functions OpenDesktop, SwitchDesktop, SetThreadDesktop
[DllImport("user32.dll", Unicode)]
public static extern IntPtr CreateDesktop (string,string,Int32,UInt32,UInt32,IntPtr);
2) when need to show Login Form,
2a) create login desktop (if it exists, it only open )
string dskName = "Logon desktop";
SECURITY_ATTRIBUTES sAtt = new SECURITY_ATTRIBUTES(){nLength=Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES)), bInheritHandle=1};
sAtt.lpSecurityDescriptor =0;
IntPtr hglobal = Marshal.AllocHGlobal(Marshal.SizeOf(sAtt));
Marshal.StructureToPtr(sAtt, hglobal, false);
IntPtr logonDsk = CreateDesktop (dskName, null, 0, 1, 0x10000000, hglobal);
Marshal.FreeHGlobal(hglobal);
2b) create new thread and login form
Thread thread = new Thread(new ThreadStart(()=>
{
logonDsk = createLoginDesk();
SetThreadDesktop(logonDsk);
SwitchDesktop(logonDsk);
loginForm = new LoginForm();
dlgResult = loginForm.ShowDialog();
var newdsk = OpenDesktop("Default",1,true,0x10000000);
SetThreadDesktop(newdsk);
SwitchDesktop(newdsk);
}));
3b) wait for finishing thread, after that get data from loginForm
p.s.: solution will be write in more details.