ippo
ippo
Explore posts from servers
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
does anyone have an idea how to do that with threads?
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
@jcotton42 there is no minimal example you can show 😦 ?
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
correct 🙂 can you help me to make that non-blocking?
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
not sure what you mean, but maybe you mean this?
PowerShell ps = PowerShell.Create();
ps.AddScript(myPsScript);

foreach (PSObject result in ps.Invoke()) {
dataGridView.Rows.Add(
result.Members["Name"].Value,
result.Members["Count"].Value,
);
}
PowerShell ps = PowerShell.Create();
ps.AddScript(myPsScript);

foreach (PSObject result in ps.Invoke()) {
dataGridView.Rows.Add(
result.Members["Name"].Value,
result.Members["Count"].Value,
);
}
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
all of these solutions are locking
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
dataGridView1.Invoke(new Action(() => {
// the foreach code
});
dataGridView1.Invoke(new Action(() => {
// the foreach code
});
dataGridView1.Invoke(new Action(() => {
// the foreach with invoke()
});
dataGridView1.Invoke(new Action(() => {
// the foreach with invoke()
});
Thread t = new Thread(() => {
dataGridView1.Invoke(new Action(() => {
// the foreach with invoke()
});
});

t.Start()
Thread t = new Thread(() => {
dataGridView1.Invoke(new Action(() => {
// the foreach with invoke()
});
});

t.Start()
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
this is what I tried:
dataGridView1.Invoke((MethodInvoker)delegate {
// the foreach code with the ps invoke()
});
dataGridView1.Invoke((MethodInvoker)delegate {
// the foreach code with the ps invoke()
});
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
as in the app is not responsive during the operation?
yes!
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
foreach (PSObject result in myCommand.Invoke()) {
dataGridView.Rows.Add(
result.Members["Name"].Value,
result.Members["Count"].Value,
);
}
foreach (PSObject result in myCommand.Invoke()) {
dataGridView.Rows.Add(
result.Members["Name"].Value,
result.Members["Count"].Value,
);
}
25 replies
CC#
Created by ippo on 5/14/2023 in #help
❔ Update Form in a new Thread!
@jcotton42 I used Invoke with Action and with delegate but nothing works I mean I get the results at the same time and not one after the other, but it is still locking the UI thread
25 replies