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);
}
}
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);
}
}
//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);
}
}
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;
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 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);
}
}
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;
}
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);
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.