In my C# WinForm program, I create a new thread to do a long process of
inserting data from Access files to SQL DB. The problem is that some parts
of the MainForm pertially disappear while the new thread is doing its task.
I found many articles on this on the Internet and followed the example from http://www.codeproject.com/csharp/workerthread.asp. Still some parts of the
MainForm (buttons) disappear and it appears that the code is not updating
the label on the MainForm properly. Are there any areas that I might be
overlooking?
The code looks like this, although this partial code may not make much
sense..
mainForm.BeginI nvoke(mainForm. delegateUpdateM ainUi, new Object[] {"Number of
records inserted: " + numberOfRecords Processed.ToStr ing()} );
Thanks,
TomTom 2 1286
Hi,
Are you updating the UI frmo the worker thread?
If so use Control.Invoke ( do a search in the archives by Control.Invoke )
and you will find a lot of code snipets that works.
IF you create a new thread the UI should work fine, unless you are
interacting with the UI frmo the worker thread.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"TomTom" <no*****@nospam fordiscussion.c om> wrote in message
news:uC******** ******@TK2MSFTN GP10.phx.gbl... In my C# WinForm program, I create a new thread to do a long process of inserting data from Access files to SQL DB. The problem is that some parts of the MainForm pertially disappear while the new thread is doing its task. I found many articles on this on the Internet and followed the example from http://www.codeproject.com/csharp/workerthread.asp. Still some parts of the MainForm (buttons) disappear and it appears that the code is not updating the label on the MainForm properly. Are there any areas that I might be overlooking?
The code looks like this, although this partial code may not make much sense..
mainForm.BeginI nvoke(mainForm. delegateUpdateM ainUi, new Object[] {"Number of records inserted: " + numberOfRecords Processed.ToStr ing()} );
Thanks, TomTom
Thanks for your answer, Ignacio.
I was using the Join() method and after I removed this, the form began to
behave as expected.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Hi,
Are you updating the UI frmo the worker thread? If so use Control.Invoke ( do a search in the archives by Control.Invoke ) and you will find a lot of code snipets that works.
IF you create a new thread the UI should work fine, unless you are interacting with the UI frmo the worker thread.
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"TomTom" <no*****@nospam fordiscussion.c om> wrote in message news:uC******** ******@TK2MSFTN GP10.phx.gbl... In my C# WinForm program, I create a new thread to do a long process of inserting data from Access files to SQL DB. The problem is that some parts of the MainForm pertially disappear while the new thread is doing its task. I found many articles on this on the Internet and followed the example from http://www.codeproject.com/csharp/workerthread.asp. Still some parts of the MainForm (buttons) disappear and it appears that the code is not updating the label on the MainForm properly. Are there any areas that I might be overlooking?
The code looks like this, although this partial code may not make much sense..
mainForm.BeginI nvoke(mainForm. delegateUpdateM ainUi, new Object[] {"Number of records inserted: " + numberOfRecords Processed.ToStr ing()} );
Thanks, TomTom
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ioannis Vranos |
last post by:
Why in this code the form *does not refresh* when it gets the focus/after some time?
#using <mscorlib.dll>
#using <system.windows.forms.dll>
#using <system.dll>
#using <system.drawing.dll>
|
by: Ger |
last post by:
My dialogue form (sometimes partly, sometimes as a whole) remains visible
during a fairly long processing job.
The dialogue asks the user to enter some data for the job to follow, and
after OK, should disappear and the processing job (Sub CreateHTML()) starts,
while showing a progress bar in the main form.
The problem is that the dialogue form stays visible and does not close
during execution of the job. It closes after the job is...
|
by: hzgt9b |
last post by:
Using VB .NET 2003,
I have a windows application that performs a series of file actions (copy,
move, delete) but the actions are completing before the window is painted on
the screen... how can I force the form to be painted on the screen first,
then the actions start? Or should I pause the app for a few seconds while the
form paints.
Any suggestion woudl be appreciated!
|
by: ortaias |
last post by:
I have a form which calls up a second form for purposes of data entry.
When closing the data entry form and returning to the main form, things
don't work as expected.
When I return to the main form, I trigger the on acitvate event to run
a macro. I can use the Dlookup function to update my fields, which is
OK. However, I intitially tried to use the Repaint Object command to
repaint the form. That did not work. Though I solved the...
|
by: jj |
last post by:
I have a single threaded application in c# that scans through a file system.
While doing this if I try to minimize, maximize buttons on the top,right
hand corner of my form do not do as they are supposed to do. To maximize the
window I have to go to "task manager" and double click the application.
How do I control those maximize, minimize buttons on the top right section
of my form?
A learner here
| |
by: Miro |
last post by:
I will try my best to ask this question correctly. I think in the end the
code will make more sence of what I am trying to accomplish. I am just not
sure of what to search for on the net.
I have a form that has a button. ( this form is a child form of a parent
form ( main form ).
Anway...in this child form I have a button, and if clicked a bunch of code
will get executed.
I would like to show a Progress Bar / form in modal/ShowDialog...
|
by: Ajith Menon |
last post by:
I have created a windows application in which the form needs to be
resized on the MouseMove event. The windows resize function takes a lot
of CPU cycles. And as the resize function is called on the MouseMove,
the form is resized around a 30-100 times in one second. This leads to
a high CPU utilization and all other application comes to a stand
still.
The form does not have any controls i.e. buttons, text boxes etc. It is
completely...
|
by: info |
last post by:
Hi All,
I am trying to set the hourglass cursor inside a class that has nothing
to do with MainForm class and I don't want to pass a reference to
MainForm.
How can I set the current cursor to Hourglass and then back to arrow?
Thanks a lot,
|
by: Zytan |
last post by:
I have public methods in a form. The main form calls them, to update
that form's display. This form is like a real-time view of data that
is changing.
But, the form may not exist (it is created / destroyed at user
request). I can check form != null to prevent incorrect access.
But, the form could disappear immediately after the check, before the
method is run. Or someone could click 'close' when it's in the middle
of an update. ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |