Solved

ShowModal and Menu problem

Posted on 2002-04-30
13
544 Views
Last Modified: 2008-02-01
I have a problem with my ShowModal form and Menu.  In the case where my application is doing a lot of processes (receiving data feed form a clientsocket, decoding the feed, loading data to memory) when i bring out a showmodal form, the application responds very very slow(about 5-10 seconds delay) that is why it looks as though it hangs.  Clicking on the Menu is also really slow or sometimes does not respond anymore.

What can i do to fix this?

thanks so much ... :)

0
Comment
Question by:ttanyag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +6
13 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6979783
depending how you do your stuff,
you could try to place some

application.processmessages;

lines into your code

meikl ;-)
0
 
LVL 1

Expert Comment

by:LoneA
ID: 6979788
Hi TTanyaq

I sounds to me as if your application doesn't process the message queue during communication. You nedd to do this frequently.

To interrupts the execution of an application so that Windows can process the message queue write:

Application.ProcessMessages;

0
 

Author Comment

by:ttanyag
ID: 6979806
I have already put application.processmessages in certain parts of my code especially in long loops.

I got this from the internet ...

implementing ShowModal as Show ...

procedure Show_Prompt;
var
WindowList: Pointer;
begin
{Disables all forms except Form2}
  WindowList := DisableTaskWindows(Form2.Handle);
  try
    Form2.Show;
    Form2.ModalResult:=0;
    Repeat
      Application.ProcessMessages;
    Until Form2.ModalResult<>0;
    //OnButtonClick - ModalResult is set
  finally
   {enable all forms again}
   EnableTaskWindows(WindowList);
   Form2.Close;
  end;
end;

but it still doesn't seem to work ... and when you choose mrNo the focus goes to another application.


i think the repeat ... until still takes up a lot of processing??? even though i have placed an application.processmessages ...



0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Cesario
ID: 6979807
Hello ttanyag,

create a thead to
  receiving data feed form a clientsocket
  decoding the feed
  loading data to memory ( With Synchronize )

Sample Code ( not Tested )

Type
  TMyThread = Class ( tThread )
    Private
      mySocket : TClientSocket;
      Procedure ClientRead (Sender: TObject;
  Socket: TCustomWinSocket);
    Protected
      Procedure Execute;
    Public
      Constructor Create; Override;
      Destructor Destory;
   End;

Constructor TMyThread.Create;
Begin
  Inherited Create(False);
  MySocket := TClientSocket.Create....
  MySocket.OnClientRead := clientRead;
End;

Destructor TMyThread.Destroy;
Begin
  MySocket.Close;
  MySocket.Free;
  Inherited Destroy;
End;

....
....

Its just an idea ;-)

Cesario
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6979821
yep, a thread could be a solution,
0
 
LVL 1

Expert Comment

by:piscean
ID: 6980069
when exactly do you display your modal form? after the "(receiving data feed form a clientsocket, decoding the feed, loading data to memory)" or during the "(receiving dat..."
if you will be showing it during processing (like displaying transfer status) don't make it modal. set FormStyle to fsStayOnTop instead and just "Show" it.
try adding processmessages() on Application.OnIdle
0
 
LVL 4

Expert Comment

by:nestorua
ID: 6981610
HI,
First of all, it seems curiosly for me to see those rows
of code:
"Form2.Show;
Form2.ModalResult:=0;"
The second, I didn't understand what the problem?
The code you didn't show to us or that while your code is
processing everything seems to become frosen.
Sincerely,
Nestorua.
0
 
LVL 1

Expert Comment

by:piscean
ID: 6983001
i think he wants a button on the "proposed" modal form to trigger something (maybe OK, Cancel ...)
0
 
LVL 4

Expert Comment

by:nestorua
ID: 6986176
HI, piscean,
Maybe you are right but let him answer the question?
Sincerely,
Nestorua.
0
 

Expert Comment

by:BasBlommaart
ID: 6990587
The Application.ProcessMessages may take too much processor capacity.

I had the same problem in the past and do suggest that you add a Sleep into your loop. Please find the code below that I used to relieve the CPU in a delay loop by adding sleep(10):


procedure Delay( AMilliSeconds: integer );
var
  iStartTick: longint;
begin
  iStartTick := GetTickCount;
  repeat
    Application.ProcessMessages;
    Sleep(10);
  until
    ((LongInt(GetTickCount) - iStartTick) >= Longint(AMilliSeconds));
end;

0
 

Author Comment

by:ttanyag
ID: 6992580
My application is a Real-Time program processing data feed form the exchange for the stock market. The showmodal form can be triggered by the user (event) may it be ordering, an error message, etc.  In the case where there is a big influx of data (ex. start of trading), the application kinda hangs when a showmodal form is shown or the menu/popmenu is clicked.

I've actually worked around the showmodal problem, but my problem still is the menu.  So the user is not able to use the menu (shortcut keys are not affected) when there is an influx of data coming in.  

As for the code above, I just experimented with it ... got it from the internet ... It is actually kinda the same code of function ShowModal in Forms.pas.

thanks for all your suggestions
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7014463
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20245974.html
http://www.experts-exchange.com/questions/Q.20247079.html
http://www.experts-exchange.com/questions/Q.20249274.html
http://www.experts-exchange.com/questions/Q.20300761.html

To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20295273.html

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 6

Accepted Solution

by:
Mindphaser earned 0 total points
ID: 7179025
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question