C
Curious
I was asked these questions during a technical interview:
1) When the user clicks on a button on the form and that invokes a lot
of heavy-duty calculations, what would you do?
My answer:
I would use "BeginInvoke" to start a background worker thread to do
the heavy-duty calculations, in order to avoid blocking the main UI
thread.
Then he asked, "What does 'BeginInvoke' do"? I said it was a .NET
pattern to start a background thread from a UI thread. Did I get it
right?
2) Why can't you simply update a button on the UI thread from a
background thread?
My answer:
If I update a button on the UI thread while the user is clicking on
the button on the UI thread, that would result in memory corruption.
Did I get this one right?
1) When the user clicks on a button on the form and that invokes a lot
of heavy-duty calculations, what would you do?
My answer:
I would use "BeginInvoke" to start a background worker thread to do
the heavy-duty calculations, in order to avoid blocking the main UI
thread.
Then he asked, "What does 'BeginInvoke' do"? I said it was a .NET
pattern to start a background thread from a UI thread. Did I get it
right?
2) Why can't you simply update a button on the UI thread from a
background thread?
My answer:
If I update a button on the UI thread while the user is clicking on
the button on the UI thread, that would result in memory corruption.
Did I get this one right?