在我的 asp.net 应用程序中,我使用 windows forms.dll 通过创建线程来使用某些 windows 控件。这在我的系统中运行良好,但在 IIS 上托管时会出现会话超时。创建线程使我在 IIS 上的会话超时。如何创建可以在 IIS 上正常工作的线程?
下面是 iam 创建线程的代码。
public string[] DisplayFileDialog()
{
string[] result = null;
try
{
Thread objThread = new Thread(state =>{
result = FnOpenFileDialog();
// TODO: do something with the returned result
});
objThread.IsBackground = false;
objThread.SetApartmentState(ApartmentState.STA);
objThread.Start();
objThread.Join();
return result;
}
catch (Exception ex)
{
return result;
}
protected string[] FnOpenFileDialog()
{
IntPtr hdlr = GetForegroundWindow();
WindowWrapper Mockwindow = new WindowWrapper(hdlr);
OpenFileDialog fDialog = new OpenFileDialog();
fDialog.Title = "Select Files";
fDialog.Multiselect = true;
fDialog.CheckFileExists = true;
fDialog.CheckPathExists = true;
System.Windows.Forms.DialogResult dr = fDialog.ShowDialog(Mockwindow);
string[] filenames = fDialog.FileNames;
return filenames;
}
提前致谢。