|
Okay wow. I was just sitting here, reading MY OWN CODE, and something hit me. Did you actually check the data stored in your data structure to see whether all of it was there, or were you just going by what it looked like? If you look at my post immediately before this, I added a call to the Sleep function in order to give a little bit of spacing between the SetCursorPos() calls. It could be that all of the data is there but you don't see smooth mouse movement because you are calling SetCursorPos too quickly. Try adding something like Sleep(10) and see if the motion is smooth. If that doesn't work, check your data structure (print it to the screen or something) and check the results against a Spy++ on the Window.
If all else fails, I can look at your code if you would care to send it to me.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Wow! that was it! Just adding a Sleep(1) call after every SetCursorPos call, made it work just fine. I guess all it needed was a moment to draw it.
Thanks!!
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Cool! Glad I could help.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
try using some sleeps
or threads
gabby
|
|
|
|
|
I believe its jumpy because there isn't enough data.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
mmm
i think you're right
gabby
|
|
|
|
|
Hello,
This time the question if about threading... hope you'll appreciate it.
Well then, I have a worker thread being created at some point in my App. It happens that this [new] thread creates about 5 modeless dialogs which continuously output data. This thread was derived from CWinThread ; Everything fine so far...
Now, this is where it gets tricky: inside the InitInstance I initialise a class, which has no links whatsoever to a message pump nor to the main frame window. Moreover, it has to execute in a kind of a loop. Here's an example:
BOOL CClass::InitInstance()
{
CG1 theG1;
theG1.Run();
return FALSE;
}
This was my first (frustrated) attempt and I quickly learned that whenever the instruction execution reached inside theG1.Run , there were no Windows Messages being received/processed.
So I made some changes. Instead of having it run inside InitInstance , I implemented a solution with OnIdle . I don't really like it, but let's see how I did it:
CClass::OnIdle(long nCount)
{
theG1.ExecuteNext();
return TRUE;
}
Now my question:
Is is possible to make the class run in a real multi-threading environment rather than in OnIdle ? I know I would have to somehow make a connection with the thread's Message Pump... but how?
Any suggestions would be greatly appreciated,
David
PS: In case you got confused with the methods I'm using above (Run ; ExecuteNext ) , I am working on an academic project aimed at emulating a processor on a x86 machine.
|
|
|
|
|
dNimrod#X wrote:
I have a worker thread being created at some point in my App. It happens that this [new] thread creates about 5 modeless dialogs...
This raises a lot of red flags, namely that worker threads should not create UI components. If you must create a UI component in a thread other than the primary thread, it should be a UI thread (i.e., thread with a message pump). See here for more.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I've been reading on the subject and decided to follow your cue. You're absolutely right -- there is the need to have a message pump thread.
Thanks very much for the reply. You have been very helpful indeed.
David
|
|
|
|
|
Hi,
I'm developing a database application using CDatabase & CRecordSet classes. My SQL Server database
is sitting on other machine and it's effecting application performance when I tried to insert large number of records
and retrieving the records for generating some reports(i.e. to fetch 1000000 records at a time for creating a report). Application is getting too slow.
Need some suggestions in this regard.
Thanks,
|
|
|
|
|
Hi,
probably instead of using mysql_store_result you should using mysql_use_result. It will give you a boost, but also a lot of drawbacks. See the C-API documentation for that.
GSte
|
|
|
|
|
Hi,
I recommend to segment this query or install more physics memory.
navisoft
www.latindevelopers.com
|
|
|
|
|
How are you using CRecordset? Are you predefining the query and the columns it returns with CRecordset, or are you simply creating a CRecordset from a query at run-time? If you are doing the former (predefining the query and the columns), there are some operations in which CRecordset performs very inefficient methods on the data, and it could be that the slowness you are seeing is because CRecordset is clogging the system memory.
Check which way you are using CRecordset and also pull up Task Manager while your long query is running to see how much system memory it is sucking up.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi,
I'm using the former one. I have to read a text file which has more than million records and insert each record at a time. Also, for genearting some reports, i've to fetch huge number of records at a time from the database and process all the records.
Thanx,
|
|
|
|
|
So, just to clarify exactly what you are trying to do: you are opening and reading a text file from which data you want to insert records into a database. Because you want to insert so many records, I would suggest using a SQL command to insert the data (INSERT INTO...) instead of CRecordset::AddNew() and CRecordsSet::Update(). The CRecordset functions for adding records tend to be slower than simply executing a SQL statement against the database. You can execute a SQL statement by using the function in CDatabase (I forget the exact name, but it is something like "Execute").
For fetching large numbers of records, I would also suggest that you move away from the default RFX (Recordset Field Exchange - where you predefine the columns returned from the query) implemented with CRecordset. Again, this tends to be slower than simple qeurying the database with SQL statement and not using RFX. For some more information on this topic, take a look at the ODBC section on CodeProject: http://www.codeproject.com/database/#ODBC[^].
If you need more specific information, or some example code, please let me know.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi Alexander,
Thanks for your input. Right now, I'm not using RFX for fetching the records nor
AddNew() and Update() functions of CRecordset classes. As you said, i'm reading each record from the text file and create INSERT INTO.. query and execute it using CDatabase
ExecuteSQL() function. However, for every call to this function, database has to parse , prepare an execution plan and compile it. Instead i'm thinking of using stored procedures. But my application has to support multipe databases like MSAccess, MySQl, Oracle & MS SQL Server. I don't think MSAccess supports Stored procedures and I'm not sure of MySQL either.
Do you have any generic database module? If so, can you send it to me?
I would appreciate your help.
Thanx,
|
|
|
|
|
Hi Sridhar,
Unfortunately, there won't be something which you can code which will take the place of a stored procedure for those DBs that don't support them. MySQL should have something you can use for optimization, although I thought it supported stored procedures. Maybe your best bet is to implement the insertion code inside a worker thread, so the main application UI doesn't seem like it isn't responding when you are doing the insert. Long operations, when necessary, are OK as long as you give the user some indication of what is actually happening and maybe a "Stop" button.
Although I can't think of anything else right now, I will keep my eyes open for something that can help you.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi Alexander,
I thought of implementing intensive database operations in the worker thread.
Think this strategy will work for inserting records. But, what about fetching if you implement it in the worker thread?
I mean, if my query is taking X number of sec or minutes to fetch Million plus records(Select * from table where condition). HOw do I cancel the worker thread if it's still in the process of retrieving?
Some insight would be greatly appreciated.
Thanks,
|
|
|
|
|
Hi Alexander,
I thought of implementing intensive database operations in the worker thread.
Think this strategy will work for inserting records. But, what about fetching if you implement it in the worker thread?
I mean, if my query is taking X number of sec or minutes to fetch Million plus records(Select * from table where condition). HOw do I cancel the worker thread if it's still in the process of retrieving?
Some insight would be greatly appreciated.
Thanks,
Sridhar
|
|
|
|
|
|
Hello everyone,
I am searching the way to find for in archives and folders recursively.
You can say me the optimal way to do it?
Thanks!
navisoft
www.latindevelopers.com
|
|
|
|
|
Take a look at this article: http://www.codeproject.com/file/fileglob.asp[^], it implements exactly what you want and more.
Hope that helps!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
you can do a function like this
int findfiles()
{
...
findfirstfile(*.*)
if file=a directory
findfile(directory)
}
gabby
|
|
|
|
|
Hai,
I'm working on win32 vc++.I want to get the user logon ID from the system and display it in my dialog(probably in a textbox).I dont know how to do that.
Can anyone help pls.
Thanks a lot in advance.
|
|
|
|
|
Hi,
You can obtain the current username writing follow code:
DWORD userNameCharCount = 255;
TCHAR userName[255];
if( !GetUserName( userName, &userNameCharCount) ){
// error!
}
CString str = userName;
GetDlgItem(IDC_YOUREDIT_CTRL)->SetWindowText(str);
navisoft
www.latindevelopers.com
|
|
|
|