Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

C# DLL Modalless Forms tab problem.

Posted on 2009-02-12
7
Medium Priority
?
463 Views
Last Modified: 2013-12-14
i wrote a c# DLL and i was create a form into DLL. my form has textarea. Form is modalless.I
I show form and i did see broken tab key. Because of this reason, I wrote this code below. Bu My cpu go to crazy like %50 CPU using when code go to Application.DoEvents.After that i try to use PeekMessage for controling incoming message. Bu t i didnt solve this question. can someone help me about performance optimization in here.


TestForm myForm;
myForm = new TestForm();
myForm.Show();
            while (!myForm.IsDisposed)
            {     
              Application.DoEvents();                                                                                                         
            }

Open in new window

0
Comment
Question by:vtokmak
  • 3
  • 3
6 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 23620220
> After that i try to use PeekMessage for controling incoming message. Bu t i didnt solve this question.

You should use GetMessage() instead of PeekMessage().
You get high CPU usage (50%, dual core by any change?) because your code is running in circles like crazy, PeekMessage() doesn't wait or anything. GetMessage() actually waits until there _is_ a message to process. Be aware though that GetMessage() actually removes the message from the queue where PeekMessage() can also leave it.
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 23620221
Other option could be to place a little delay in your while loop...
0
 

Author Comment

by:vtokmak
ID: 23621014
i tried GetMessage here like

TestForm myForm;
myForm = new TestForm();
myForm.Show();
            while (!myForm.IsDisposed)
            {    
                 if GetMessage(&msg,FormHandle,0,0)
                   {
                     Application.DoEvents();    
                   }                                                                                                    
            }
I saw there, My CPU problem solved but i lost tab events :)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:vtokmak
ID: 23621029
When i try to delay like sleep(10) , i saw , my form flicking when i wrote someting on textbox. I need to capture tabchange events with normal CPU usage
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 23621122
Please try this (pseudo code!):
TestForm myForm;
myForm = new TestForm();
myForm.Show();
            while (!myForm.IsDisposed)
            {     
              if (!PeekMessage())
                WaitMessage();
              Application.DoEvents();                                                                                                         
            }

Open in new window

0
 

Accepted Solution

by:
vtokmak earned 0 total points
ID: 23937281
nothing. I discuss some people from microsoft about this problem. I are not support COM DLL for this works. we can only use this style on Internet Explorer. Basic solution is Sleep after While loop. I try to Sleep(250) sound is good.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 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