2011-07-14 69 views
-1
public void spawnVr_Monthly() { 
    vrMonthlyProcessingThread = new Thread(new ThreadStart(process_Vr_Monthly_File)); 
    vrMonthlyProcessingThread.Start(); 
} 
public void process_Vr_Monthly_File() { 
    OpenFileDialog vrmpf = new OpenFileDialog(); 
    vrmpf.AutoUpgradeEnabled = true; 
    vrmpf.Title = "Select VR Monthly Parking file to process"; 
    vrmpf.Filter = "VR Monthly Parking File (VRMTHY_OUT*.TXT|*.TXT"; 
} 
+1

你真的顯示對話框嗎?您顯示的代碼不完整。 –

+0

OpenFileDialog不能用於非STA的工作線程。有關詳細信息,請參閱Thread.SetApartmentState()。無論您在該XP機器上使用哪種.NET版本,都會忘記提醒您。 –

回答

2

您的Main()函數中是否有[STAThread]屬性?

我想你最好在UI線程上產生這個對話框,而不是任何背景。使用SynchronizationContext或Control.Invoke()在UI線程上運行某些內容。

相關問題