Hi all,
I ran into a headache problem. I have a windows form with a progress
bar on it. Then I new a thread to do calculation for a long time. I
want the progress bar to show the calculation progress. So I use a
shared variable in calculation thread to allow main thread read it
periodically in order to show the progress. Quesion comes out. If I
just wait and don't make any operation during the whole calculation,
the main form is OK, with progress bar increased step by step. But If
I click other application or just drag the form, main form will have
no response until the calculation finished. At first I think that
maybe the calculation is too tight to be a circle. So I add several
sleep() in it. But this method is of no use. I have no idea this time.
Anybody can help me? Thanks in advance! 2 2390
I ran into a headache problem. I have a windows form with a progress
bar on it. Then I new a thread to do calculation for a long time. I
want the progress bar to show the calculation progress. So I use a
shared variable in calculation thread to allow main thread read it
periodically in order to show the progress. Quesion comes out. If I
just wait and don't make any operation during the whole calculation,
the main form is OK, with progress bar increased step by step. But If
I click other application or just drag the form, main form will have
no response until the calculation finished. At first I think that
maybe the calculation is too tight to be a circle. So I add several
sleep() in it. But this method is of no use. I have no idea this time.
Anybody can help me? Thanks in advance!
Does the main thread launch your worker thread and then immediately enter
some loop to periodically check the shared variable? It certainly appears
that way and if so then it's not correct. You can Google for "Windows
message loops" to understand why but to correct the problem you may want to
have a look at the "BackgroundWork er" class. It's designed to handle exactly
what you're trying to do although you can still resort to other conventional
means if you want (once you read up on Windows message loops but why bother
when "BackgroundWork er" makes life easier).
On Jun 21, 12:06 am, "Larry Smith" <no_spam@_nospa m.comwrote:
I ran into a headache problem. I have a windows form with a progress
bar on it. Then I new a thread to do calculation for a long time. I
want the progress bar to show the calculation progress. So I use a
shared variable in calculation thread to allow main thread read it
periodically in order to show the progress. Quesion comes out. If I
just wait and don't make any operation during the whole calculation,
the main form is OK, with progress bar increased step by step. But If
I click other application or just drag the form, main form will have
no response until the calculation finished. At first I think that
maybe the calculation is too tight to be a circle. So I add several
sleep() in it. But this method is of no use. I have no idea this time.
Anybody can help me? Thanks in advance!
Does the main thread launch your worker thread and then immediately enter
some loop to periodically check the shared variable? It certainly appears
that way and if so then it's not correct. You can Google for "Windows
message loops" to understand why but to correct the problem you may want to
have a look at the "BackgroundWork er" class. It's designed to handle exactly
what you're trying to do although you can still resort to other conventional
means if you want (once you read up on Windows message loops but why bother
when "BackgroundWork er" makes life easier).
Hi Larry,
BackgroundWorke r, really cool. That works!
I think over for my periodical checking status in main thread, that
should be blocked in main form. But what about using a timer, I
haven't tried that. My intuition is that timer maybe OK. Anyway, I'll
spend my time in studying Windows message loops after finishing. Thank
you very much! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Paul |
last post by:
HI! I get an error with this code.
<SCRIPT language="JavaScript">
If (ifp==""){
ifp="default.htm"}
//--></SCRIPT>
Basicly I want my iframe to have a default page if the user enters in
directly. so I need a way doing this. so I check to see if the ifp value is
null and if so then assign it a value. is this correct?
|
by: Drew Stoddard |
last post by:
We are working in C#/Winforms and are using asynchronous client-side web
service calls (the Begin... and End... methods supplied by the web reference
creation). Many of these calls are contained in Windows forms that the user
can close before the web service call has completed. This seems to be
working fine, but I wanted to check to see if anyone has experienced any
problem with this. Specifically this is what I need to know: Is it...
|
by: William Bradley |
last post by:
I have a production table and its accompanying form. There can be up to ten
ingredients in what is produced.
The ingredients are obtained from the incoming goods table which supplies
the two parameters that I use, "Name" and "CatlogNo".
This production table needs to contain each ingredient by name and catalogue
number. With help from this list I was able to set up a combo box that
allowed me to select a particular ingredient, and when...
|
by: Alice |
last post by:
Hi,
In my program, the user can navigate to many different
forms. When they go to the next form, I want the form they
have left to close.
However, the forms aren't closing. Can anyone tell me what
I'm doing wrong? Here is a sample snippet of code where
the user can return to the main form while simultaneously
closing the previous form.
|
by: michdoh |
last post by:
Hi All
I'm looking for some help on creating a basic multi threaded
application.
i'n new to threads in this environment so for test purposes I've
produced a very basic program. (which doesn't work)
Calling the 2 methods directly has the desired effect however when I
try to impelment them as threads nothing happens.
| |
by: Jordan |
last post by:
All,
I have a UI form calling a class object that contains a timer that
routinely draws intensive information to the screen (~30 fps). The
drawing is invoked on the main UI thread. I need the user to be able
to interact with the UI while the drawing is happening (dynamically
change drawing properties). Since the drawing is happening on the main
UI thread, the UI form doesn't receive the user control events
consistently (if at all).
|
by: Kandiman |
last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?...
heres the code.. i think its on the value=true for the hidden textbox on the logout sub.. but how do i get round this? can i not change the value onclick?
<div id=Rightbody>
<!--<form id="RightBodyForm" name="RightbodyForm" method="post" action="Guestbook2.asp">-->
<%
Response.Expires...
|
by: bpw22az |
last post by:
Bare with me guys. I will try and make this short and to the point. I have a website that allows students to check their admission status by submitting their email address which in turn sends them and our admissions office an email regarding their status in our SQL database. The ASP script that runs pulls all information from one table.
There are three possible status types; 'AC (App Complete), AI (App Incomplete), and UR (Under Review)'. ...
|
by: bruce |
last post by:
Hi.
Got a test web page, that basically has two "<html" tags in it. Examining
the page via Firefox/Dom Inspector, I can create a test xpath query
"/html/body/form" which gets the target form for the test.
The issue comes when I examine the page's source html. It looks like:
<html>
<body>
</body>
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |