Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing Form Window in another thread
    primarykey
    data
    text
    <p>How do i add an entry in a listbox in a window that is in another thread. My Problem is, that i have to threads. One working thread, that does all the actual work and one thread for a window where i want to display status information. I tried to pass the form window as paramater in the constructor, but when i call it i get an exception.</p> <p>Here is some of my code to illustrate the problem:</p> <pre><code>public partial class Mainform : Form { private string db = String.Empty; private string password = String.Empty; private string sqlinifile = String.Empty; DatabaseListener dbListener; StatusWindow statusWindow; public Mainform() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // db = "EWAG"; password = "secret"; sqlinifile = "C:\\Programme\\Unify\\Team Developer 5.2\\sql.ini"; textBoxDB.Text = db; textBoxPwd.Text = password; textBoxSqlIni.Text = sqlinifile; statusWindow = new StatusWindow(); dbListener = new DatabaseListener(statusWindow); } public void threadStarter() { this.dbListener.startSynchronizing(5); } void Button1Click(object sender, EventArgs e) { this.db = textBoxDB.Text; this.password = textBoxPwd.Text; this.sqlinifile = textBoxSqlIni.Text; if (dbListener.connectToDatabase(db,"sysadm", password, sqlinifile)) { this.Hide(); statusWindow.Show(); Thread synchronizer = new Thread(new ThreadStart(threadStarter)); synchronizer.Start(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload