Click here to Skip to main content
15,887,335 members
Home / Discussions / C#
   

C#

 
GeneralRe: BackGroundWorker gives runtime error Pin
OriginalGriff12-Feb-21 2:11
mveOriginalGriff12-Feb-21 2:11 
GeneralRe: BackGroundWorker gives runtime error Pin
Alex Dunlop12-Feb-21 6:03
Alex Dunlop12-Feb-21 6:03 
AnswerRe: BackGroundWorker gives runtime error Pin
Ralf Meier10-Feb-21 4:48
mveRalf Meier10-Feb-21 4:48 
GeneralRe: BackGroundWorker gives runtime error Pin
Alex Dunlop10-Feb-21 4:57
Alex Dunlop10-Feb-21 4:57 
GeneralRe: BackGroundWorker gives runtime error Pin
Alex Dunlop10-Feb-21 7:47
Alex Dunlop10-Feb-21 7:47 
GeneralRe: BackGroundWorker gives runtime error Pin
Luc Pattyn10-Feb-21 9:26
sitebuilderLuc Pattyn10-Feb-21 9:26 
GeneralRe: BackGroundWorker gives runtime error Pin
Alex Dunlop10-Feb-21 16:49
Alex Dunlop10-Feb-21 16:49 
GeneralRe: BackGroundWorker gives runtime error Pin
Luc Pattyn10-Feb-21 17:22
sitebuilderLuc Pattyn10-Feb-21 17:22 
Invoke is explained well in the article I provided. However:

If the big calculation (how long would it take on the GUI thread anyway?) is accessing a GUI Control all the time, then it makes little sense to delegate that to another thread, as you would need lots of Invoke operations (much code and much delay, switching a thread for just a few lines of calculations is silly).

There are two other approaches possible:

1. Use a DataTable of a DataSet; load those with the data, perform your calculations on them, then (re)display them somehow. I'm not familiar with the DevExpress sheet, I assume it knows how to display (or bind) to a DataTable. So you could show the original data, start computations in BGW, and have it pass the new state of the DataTable say every second, so the user sees progress (assuming it all takes several seconds, can't tell from what you have shown).
If you use binding (I don't!), chances are you must undo the bind before and redo it after the big computation (and also redo and undo it if relevant in progress handling).

2. Second alternative, very simple: Do everything on the GUI thread, start by showing a WaitCursor (so user knows and accepts he is not in charge for some time), then do what you want; if you want the user to see progress, call the Refresh method of the Control of interest (e.g. a ProgressBar); be careful to do that sporadically (say after dealing with 10 or 100 rows, roughly once a second would be enough), otherwise the execution will be extremely slow.

FYI: MessageBox is thread-safe, you can always call it, whatever thread you're on.

PS: No, I haven't read anything in your description that would warrant more than one BGW (or one extra thread).

Smile | :)
Luc Pattyn [My Articles]
If you can't find it on YouTube try TikTok...

GeneralRe: BackGroundWorker gives runtime error Pin
Alex Dunlop13-Feb-21 8:24
Alex Dunlop13-Feb-21 8:24 
GeneralRe: BackGroundWorker gives runtime error Pin
Luc Pattyn13-Feb-21 8:28
sitebuilderLuc Pattyn13-Feb-21 8:28 
AnswerRe: BackGroundWorker gives runtime error Pin
Ralf Meier10-Feb-21 20:22
mveRalf Meier10-Feb-21 20:22 
AnswerRe: BackGroundWorker gives runtime error Pin
Eddy Vluggen11-Feb-21 14:21
professionalEddy Vluggen11-Feb-21 14:21 
QuestionMonitor data using C# and ESP8266 Pin
pinout_19-Feb-21 1:56
pinout_19-Feb-21 1:56 
AnswerRe: Monitor data using C# and ESP8266 Pin
OriginalGriff9-Feb-21 2:20
mveOriginalGriff9-Feb-21 2:20 
GeneralRe: Monitor data using C# and ESP8266 Pin
pinout_19-Feb-21 2:31
pinout_19-Feb-21 2:31 
AnswerRe: Monitor data using C# and ESP8266 Pin
Gerry Schmitz9-Feb-21 7:54
mveGerry Schmitz9-Feb-21 7:54 
QuestionSerialize File from one format(AMI ) to another(BAI2) format Pin
Sasikalav8-Feb-21 19:31
Sasikalav8-Feb-21 19:31 
AnswerRe: Serialize File from one format(AMI ) to another(BAI2) format Pin
OriginalGriff8-Feb-21 20:04
mveOriginalGriff8-Feb-21 20:04 
QuestionExistence of “Add” Function causes WCF to Fail Pin
Bernhard Hiller8-Feb-21 0:44
Bernhard Hiller8-Feb-21 0:44 
AnswerRe: Existence of “Add” Function causes WCF to Fail Pin
Pete O'Hanlon8-Feb-21 1:42
mvePete O'Hanlon8-Feb-21 1:42 
GeneralRe: Existence of “Add” Function causes WCF to Fail Pin
Bernhard Hiller8-Feb-21 2:10
Bernhard Hiller8-Feb-21 2:10 
GeneralRe: Existence of “Add” Function causes WCF to Fail Pin
Pete O'Hanlon8-Feb-21 2:12
mvePete O'Hanlon8-Feb-21 2:12 
GeneralRe: Existence of “Add” Function causes WCF to Fail Pin
OriginalGriff8-Feb-21 4:01
mveOriginalGriff8-Feb-21 4:01 
GeneralRe: Existence of “Add” Function causes WCF to Fail Pin
Bernhard Hiller8-Feb-21 4:03
Bernhard Hiller8-Feb-21 4:03 
AnswerRe: Existence of “Add” Function causes WCF to Fail Pin
Gerry Schmitz8-Feb-21 4:45
mveGerry Schmitz8-Feb-21 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.