Login Register


I have a problem with Background worker in C# filter_list
Author
Message
I have a problem with Background worker in C# #1
Any problem with that code below? I have a problem while I try to show form or any thing related to form such as textbox, listbox, button.... Any command? Thank before hands.
Code:
private void Timer_Tick(object sender, EventArgs e) { if (backgroundWorker1.IsBusy == false) { backgroundWorker1.RunWorkerAsync(this); } } private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { try{ this.Show(); this.notifyIcon1.Visible = false; this.ShowInTaskbar = true; this.WindowState = FormWindowState.Normal; }catch(Exception ex) { MessageBox.Show(ex.Message); } }

Reply

RE: I have a problem with Background worker in C# #2
What exactly are you trying to do here with the background worker?
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: I have a problem with Background worker in C# #3
I want to show form with it and use other tools such as textbox but I have a problem and cannot access to show form or cannot access to use other method of textbox.[/align]

Reply

RE: I have a problem with Background worker in C# #4
Why are you doing this in a background worker just to show a form? If you want to show the form and do it in a multi-threaded method:

Code:
new Thread(x => new Form1().Show());
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: I have a problem with Background worker in C# #5
It's not work..... any thing else?

Reply

RE: I have a problem with Background worker in C# #6
What do you mean not working? Post the code you have.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: I have a problem with Background worker in C# #7
I think that Background Worker doesn't work with Windows Form component! So I need your suggestion to use Background worker with Windows Form component.

Reply

RE: I have a problem with Background worker in C# #8
Sorry late night yesterday for me, I didn't even test the code I gave before because I was just about to head to sleep (start work again today). Invoke it to create a new instance of the form.

Code:
public Form1() { InitializeComponent(); bg_worker.DoWork += new DoWorkEventHandler(bg_work); bg_worker.ProgressChanged += new ProgressChangedEventHandler(bg_progress); bg_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_completed); } public BackgroundWorker bg_worker = new BackgroundWorker(); private unsafe void button1_Click(object sender, EventArgs e) { bg_worker.RunWorkerAsync(); } private void bg_work(object sender, EventArgs e) { this.Invoke((MethodInvoker)delegate { new Form1().Show(); }); } private void bg_progress(object sender, EventArgs e) { //Progress for other things here } private void bg_completed(object sender, EventArgs e) { //Completed code here bg_worker.Dispose(); }
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: I have a problem with Background worker in C# #9
Ohhh!!! Ok!! Thank you in advance!!! It's work for me!

Reply







Users browsing this thread: