private void Export_Click(object sender, EventArgs e)
{
Thread add = new Thread(() => ExportDoc());
add.IsBackground = true;
add.Start();
}
private void ExportDoc()
{
if (Total)
{
//export to word & save the doc
}
else
{
MessageBox.Show("Press The Populate Info Button First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can anyone show me how to fix it?
private void Export_Click(object sender, EventArgs e)
{
Thread add = new Thread(() => ExportDoc());
add.IsBackground = true;
add.Start();
}
private void ExportDoc()
{
if (Total)
{
//export to word & save the doc
}
else
{
MessageBox.Show("Press The Populate Info Button First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can anyone show me how to fix it?
//Add these to the top of your project
using System.IO;
using System.Threading;
//Add this to the button that exports!
saveFileDialog.ShowDialog();
if (saveFileDialog.FileName == null)
return;
Thread write = new Thread(() => writing(saveFileDialog.FileName));
write.IsBackground = true;
write.Start();
//Add this under the button you use to export!
private void writing(string filename)
{
try
{
using (StreamWriter File = new StreamWriter(filename))
{
foreach (var Acc in Accounts)
{
File.WriteLine(Acc.Username + ":" + Acc.OAuth);
}
}
MessageBox.Show("Accounts Exported", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
}
}
private void Export_Click(object sender, EventArgs e)
{
Thread add = new Thread(() => ExportDoc());
add.IsBackground = true;
add.Start();
}
private void ExportDoc()
{
if (Total)
{
//export to word & save the doc
}
else
{
MessageBox.Show("Press The Populate Info Button First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can anyone show me how to fix it?
checkforillegalcrossthreads = false;

//Add these to the top of your project
using System.IO;
using System.Threading;
//Add this to the button that exports!
saveFileDialog.ShowDialog();
if (saveFileDialog.FileName == null)
return;
Thread write = new Thread(() => writing(saveFileDialog.FileName));
write.IsBackground = true;
write.Start();
//Add this under the button you use to export!
private void writing(string filename)
{
try
{
using (StreamWriter File = new StreamWriter(filename))
{
foreach (var Acc in Accounts)
{
File.WriteLine(Acc.Username + ":" + Acc.OAuth);
}
}
MessageBox.Show("Accounts Exported", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
}
}
checkforillegalcrossthreads = false;

but i used to do it 
private delegate void SetOnFailedCallback(string title, string message);
private void OnFailed(string title, string message){
if(InvokeRequired){
Invoke(new OnFailedCallback(OnFailed), new object[]{string,message});
} else {
doStuff();
}
}
but i used to do it 
private delegate void SetOnFailedCallback(string title, string message);
private void OnFailed(string title, string message){
if(InvokeRequired){
Invoke(new OnFailedCallback(OnFailed), new object[]{string,message});
} else {
doStuff();
}
}

private void Export_Click(object sender, EventArgs e)
{
Thread add = new Thread(() => ExportDoc());
add.IsBackground = true;
add.Start();
}
private void ExportDoc()
{
if (Total)
{
//export to word & save the doc
}
else
{
MessageBox.Show("Press The Populate Info Button First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Can anyone show me how to fix it?
Func<int> del = delegate()
{
textBox1.text = "Text here";
return 0;
};
Invoke(del);
or
delegate void SetTextCallback(string text);
private void SetText(string text)
{
if (textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
textBox1.Invoke(d, new object[] { text });
}
else
textBox1.Text = text;
}
checkforillegalcrossthreads = false;
private delegate void SetOnFailedCallback(string title, string message);
private void OnFailed(string title, string message){
if(InvokeRequired){
Invoke(new OnFailedCallback(OnFailed), new object[]{string,message});
} else {
doStuff();
}
}
Func<int> del = delegate()
{
textBox1.text = "Text here";
return 0;
};
Invoke(del);
or
delegate void SetTextCallback(string text);
private void SetText(string text)
{
if (textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
textBox1.Invoke(d, new object[] { text });
}
else
textBox1.Text = text;
}
Didn't know where to start...I replaced textbox1 with bikedet (the one causing the problem) but the error still popped up
Didn't know where to start...I replaced textbox1 with bikedet (the one causing the problem) but the error still popped up
private void ExportDoc()
{
if (Total)
{
Func<int> del = delegate()
{
//put you function here
return 0;
};
Invoke(del);
}
else
{
MessageBox.Show("Press The Populate Info Button First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ExportDoc()
{
if (Total)
{
Func<int> del = delegate()
{
//put you function here
return 0;
};
Invoke(del);
}
else
{
MessageBox.Show("Press The Populate Info Button First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Thanks a lot - that got it :yes:
Copyright © 2026, NextGenUpdate.
All Rights Reserved.