|
Pointers to windows can't be used between multiple threads. Try passing just the window handle.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Is your window in the ptp structure part of your ThreadFunc, or the primary thread. Because it is generally not a good idea to call functions for a window, unless it is the same thread that owns the window. In most cases it will just not work.
Also, even if the function is setting the cursor to the wait cursor, the most likely reason that it is not showing is because the WM_SETCURSOR message handler is setting the cursor back the arrow.
What you can do is set a variable in your window object, then handle the WM_SETCURSOR message in your window. This message should call SetCursor() with the wait cursor while that certain bit is set, and pass the message to defwindowproc when that value is not set.
|
|
|
|
|
This is the exact solution that I need. Thank you, kilowatt!
|
|
|
|
|
Use something like:
::PostMessage(hWnd,WM_USER_THREAD_STARTED,0,0);
OnThreadStarted(...
{
BeginWaitCursor();
}
OnThreadfinished(...
{
EndWaitCursor();
...
}
|
|
|
|
|
I have written a TFTP server using CSocket, and CAsyncSocket. I have also re-written it using the SDK socket functions (no MFC). No matter what I do, a 6MB file is taking about 77 seconds (at 512 byte block sizes).
Unfortunately, I cannot make use of the Block Size option to gain speed. The client will not be able to handle it. Re-writing the client is not an option.
We tried a Linux TFTP server, and it transferred the file in about 12 seconds!
Any ideas on why there is such a big difference, or how I can speed things up?
I also tried playing with the thread priorities, and got no increase in performance.
I have tried other servers off the web, and they all perform the same.
Is it possible to get a TFTP server to transfer a file with speeds similar to Linux?
Thank you,
David
|
|
|
|
|
Those huge differences in performance are by no means justified. My hunch is you're doing something wrong. Maybe if you could post the code where you do the transfer we could see a little further.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here is where the code will spend most of it's time. This loop is sending the next block (512 byte size) of the file requested.
It calls SendBlock() listed below this loop.
The UpdateStatus, and all if it's formatting routines were disabled, just to see if that was the cause.
Sorry about the formatting, I can't seem to find the help on how to insert source code without losing the formatting from Visual Studio.
while (!m_bDone){
m_bCancelRetry = TRUE;
m_nRetryCount = 0;
//Sending a file
if (pbyData[0] == 0x00 && pbyData[1] == 0x04){
//ACK
if (pbyData[2] == HIBYTE(m_nBlockID) &&
pbyData[3] == LOBYTE(m_nBlockID)){
//ACK'd the last block we sent:
if (m_nBlockID == m_nLastBlockID){
m_nBlockID = -1;
AddReportString("Transfer complete.");
DWORD dwTime = GetTickCount();
CString szTime;
szTime.Format("Time to complete = %.2f seconds",(float) (((float)dwTime - (float)m_dwStartTime) / 1000));
AddReportString(szTime);
Abort();
}
else{
m_nBlockID++;
SendBlock();
}
}
else{
//Send the last block
//(no m_nBlockID++) increment here
SendBlock();
}
}
nResult = recvfrom(m_hSock,(char*)m_recvBuf,9126,0,&sockAddr,&nSockAddrLen);
if (nResult == SOCKET_ERROR){
DWORD dwErr = GetLastError();
CString szErr;
szErr.Format("RecvFrom() error = %08lX",dwErr);
AddReportString(szErr);
bErr = TRUE;
m_bDone = TRUE;
}
}
int CClientSock::SendBlock()
{
int nRet = 0;
m_bySend[0] = 0x00;
m_bySend[1] = 0x03; //Data
m_bySend[2] = HIBYTE(m_nBlockID);
m_bySend[3] = LOBYTE(m_nBlockID);
DWORD dwPos = (m_nBlockSize * (m_nBlockID - 1));
BYTE *pSrc = (m_FileData.GetData() + dwPos);
int nNum = m_nBlockSize;
if ((dwPos + nNum) > m_dwFileDataLength){
nNum = m_dwFileDataLength - dwPos;
}
memcpy(&(m_bySend[4]),pSrc,nNum);
sockaddr_in sockTo;
sockTo.sin_family = AF_INET;
int nToLen = sizeof(sockTo);
sockTo.sin_addr.s_addr = inet_addr((LPSTR)(LPCTSTR)m_szClientIP);
sockTo.sin_port = htons(m_nClientPort);
nRet = sendto(m_hSock,(char*)m_bySend,nNum + 4,0,(struct sockaddr*)&sockTo,nToLen);
if (nRet == SOCKET_ERROR){
DWORD dwErr = GetLastError();
CString szMsg;
szMsg.Format("Error %08lX found while sending file to client.",
dwErr);
AddReportString(szMsg);
}
else{
float pct = (float)(((float)dwPos / (float)m_dwFileDataLength) * 100.0);
CString szStat;
szStat.Format("%s: %lu bytes sent (%.0f%%)",m_szSendFile,dwPos,pct);
m_pServer->UpdateStatus(m_nSocketID,szStat);
}
return nRet;
}
|
|
|
|
|
I think I see the problem now. Thanks for taking a look at it.
|
|
|
|
|
I see lots of articles about downloading, but I need help on uploading files to an ftp server, can someone help me please.
Thanks.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
if you go to the search in the corner and search the message boards for "ftp" the third topic down is "Can´t implement CInternetSession" look there for some help.
-dz
|
|
|
|
|
http://codeguru.com/internet/ftpget.html
|
|
|
|
|
I found an article on codeguru that solved my problem. Thanks.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
is there a way to deselect an item from a list.
i have tried
m_drvlist.SetItemState(iItem, LVIS_DROPHILITED,LVIS_DROPHILITED);
but it does not seem to do anything.
thank you.
|
|
|
|
|
found my problem
m_drvlist.SetItemState(iItem,0,LVIS_SELECTED);
|
|
|
|
|
Anyone seen an OO command line parser for regular C++/ATL/WTL?
Figured I'd ask before I write my own.
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
Check out the one from Sells Brothers.
Tools
Look for command line parser.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
look in the C++/MFC section under "parsers", there's like 5 of them in there. (including my own STL-based parser)
-c
All programmers are playwrights, and all computers are poor actors.
Smaller Animals Software, Inc.
|
|
|
|
|
CCmdLine works great. I tried the Sells Brothers parser first but found it to be a little bit over-engineered for my purposes.
thanks all
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
Hello programmers, i want to make my application start everytime my computer is turned on. Does anybody have the knowledge of doing this ??????? THANK YOU ALL IN ADVANCE !!!!!!!!! HAPPY PROGRAMMING
the smelly man ? lol
|
|
|
|
|
this has nothing to do with programming..
if you look at the help system for windows it tells you how to make things run at startup.. just put a shortcut in start/programs/startup.. and if you are talking about something you have coded that you want to run at startup then you would have your installer do this for you.
btw.. nice topic
-dz
|
|
|
|
|
Mr I DONT NO wrote:
THANK YOU ALL IN ADVANCE !!!!!!!!! HAPPY PROGRAMMING
YOU COULD WRITE IT AS A SERVICE
Oops. Dunno how that happened. I turned the caps lock on and all the letters went big
Nish
Make MSDN universal, FREE!
|
|
|
|
|
Nish [BusterBoy] wrote:
Dunno how that happened
And you think I'll believe you?
Philip Patrick
Web-site: www.saintopatrick.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
You can also put a registry entry under Run, I always forget where that is, I search for RunOnce and it's just above.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Christian Graus wrote:
You can also put a registry entry under Run, I always forget where that is, I search for RunOnce and it's just above.
It's in two places:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
and
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
with the obvious difference between the two.
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
I just add an internet explorer object to the project, add a test method and propertie, and compile. When I open the html test file, close it, and try to recompile the source, this menssage apper:
Compiling...
TesteCtl.cpp
Linking...
LINK : LNK6004: Debug/Teste.dll not found or not built by the last incremental link; performing full link
LINK : fatal error LNK1104: cannot open file "Debug/Teste.dll"
Error executing link.exe.
Teste.dll - 1 error(s), 0 warning(s)
And, when I can't delete the file from windows explorer.
Any one know how to solve this?
Thanks
|
|
|
|