in addtion to my solution, you can keep it running by adding window message loop to your thread, some thing like this :-
MSG lpmdg;
while(GetMessage(&lpmdg,0,0,0))
{
DispatchMessage(&lpmdg);
}
i forget, how to handle dialog close here, but let you know how to do that!