public Main()
{
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
//Do Work
}
private void Start()
{
backgroundWorker1.RunWorkerAsync(); //This works perfectly
//////////This isthe offending code////////////
try
{
string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + "FileName.ini";
using (var stream = File.Create(path)) { }
File.WriteAllText(path, "Text to write");
file = txtFilePath.Text;
}
catch (Exception ex)
{
MessageBox.Show(
"Error saving configuration file.");
}
//////////////////////////////////////////
backgroundWorker1.RunWorkerAsync(); //If moved here it does not fire!
//Program contines here...
}
不知道問題可能出在哪裏。Backgroundworker not firing
這是相當難以相信。代碼是否可達? – Jonesopolis
是可以到達的。它通過它 – kr13
我認爲「一些代碼行」是這個謎的重要組成部分。 –