|
I think I misread your initial post - I thought there were two cards - is the MAC address then the same for each arp entry?
Hmmm... seems to be treating them as localhost entries - any oddities in the system32\hosts file?
oops - I mean systen32\drivers\etc\hosts
|
|
|
|
|
The MAC address is different for each entry
|
|
|
|
|
I am investigating an issue with some software at work and am looking for some suggestions. The software takes messages from a source outside of the application and will display them, one by one, to a list control. The list control is set to have a max size and will delete an entry before inserting one when it has reached its max.
The problem is that occassionally, the messages are available at such a fast rate, that they are missed by the application. I have done some experimenting and have found that when a portion of the list control is covered by another window, the messages are no longer being missed. This leads me to believe this is an issue with involving time spent refreshing the control. Any input is appreciated. Thanks.
-Andrew
|
|
|
|
|
Storing the messages internally and displaying them on demand via a virtual list control sounds like it might work for you. I thought there was an article on the subject here on CP; unfortunately i can't find it now. A Google search should find what you need though.
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
Hi,
I'm a new babie in Thread programming, and now i'm trying to taste what is thread programming. Now I got a sample program that using <process.h> library. It uses _beginthread(transaction1, 0, (void *) obj) to create a thread. My questions are:
1. What are those parameters mean?
2. I know....end_thread() is to end the thread....but can I suspend awhile and then resume a thread??? What are their function names?
3. If I want to create 1000 transaction at once (doing the same thing), can I use a for loop to loop 1000 times and create this thread?? If YES, how can i choose which thread to end/suspend/resume???
e.g. for i = 1 to 1000
_beginthread(transaction, ..... )
I got lots of articles about thread in MFC. But i just want to understand this sample program first. Can anyone help me????
THANK YOU!!!!!!!!!!!!!!!!
|
|
|
|
|
Hi,
1) The first parameter is the function which will represent the execution of your thread.. in other words, this function is going to be call after _beginthread(...)
Second one is the Stack Size, 0 most of the time.
<documentationcopypaste>
The operating system handles the allocation of the stack when either _beginthread or _beginthreadex is called; you do not need to pass the address of the thread stack to either of these functions. In addition, the stack_size argument can be 0, in which case the operating system uses the same value as the stack specified for the main thread.
Third: This can be a pointer to any type (struct, object, primitive type, etc..) you need. For example, if you need to pass several variables to the thread, probably the best way is to create a struct (or object) containing this variables and pass a pointer to this struct.
2) Search for Mutex or Semaphore, I think this is what you are looking for.. or maybe Sleep(...) if you want to suspend a thread for a given time.
3) You could, which does not mean is a good idea .
you probably don't want to create 1000 threads cause it produce resources overhead.
hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
ChiYung wrote:
I know....end_thread() is to end the thread....
Don't do that... it is bad.
I vote pro drink
|
|
|
|
|
Hi.
ChiYung wrote:
_beginthread(transaction1, 0, (void *) obj)
Make sure that obj is a pointer to a dynamically allocated object, or in some other way a pointer to data that won't magically disappear like a stack variable will.
ChiYung wrote:
2. I know....end_thread() is to end the thread....but can I suspend awhile and then resume a thread??? What are their function names?
SuspendThread() and ResumeThread() handle this. The standard, safe way for your thread to exit is when you exit your thread proc. Calling end_thread() or TerminateThread() is , as mentioned below, a Bad Thing.
ChiYung wrote:
If YES, how can i choose which thread to end/suspend/resume???
Take a look at using AfxBeginThread() instead. It returns a CWinThread* and that class contains a handle to the thread. That comes in handy when you want to make sure, for instance, that your thread has terminated before you do something else - you can call WaitForSingleObject(pThread->m_hThread, cbAlertable) to wait until the thread finishes - the handle will be signalled when it is.
Additionally, if you want to start a thread suspended, do some processing, and then resume the thread you can pass the suspended flag in to AfxBeginThread(), and then call ResumeThread() when you're ready to wake it up again.
One other thing that you reeeeeeeaally want to watch out for is data synchronization between threads. Check into the CMutex, CSemaphore & CCriticalSection classes to lock a data variable while you're using it and then unlock it when done. This prevents other threads from altering it underneath you, another Bad Thing.
The other bane of multithreaded programming is the dreaded race condition, where two threads are spinning along, and it's just sheer chance who does which operation first. That's a real pain in the tookus to debug. Using the synchronization objects and also using events (CreateEvent()) and waiting on them via WaitForSingleObject() can help there.
Of course, once you start working with blocking on events, etc. you run the risk of a deadlock, where 2 locks happen, but each is waiting for the other to let go, resulting in two threads that stand still until dinner at the Restaraunt at the End of the Universe (Milliway's, of course).
Ain't multithreaded programming fun? Actually, the best advice I have about threading is Obe Wan's line from the first Star Wars movie -
"Run, Luke!"
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
Ain't multithreaded programming fun? Actually, the best advice I have about threading is Obe Wan's line from the first Star Wars movie -
"Run, Luke!"
LOL...
To me, multithreaded applications are a lot like pointers. The first time you see them, you run for your life. But after you get a few applications under your belt, they really aren't that bad.
After doing it for nearly 15 years, I just naturally think multithreaded now.
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?
|
|
|
|
|
Tim Smith wrote:
To me, multithreaded applications are a lot like pointers. The first time you see them, you run for your life.
There's a legend at my shop of one programmer who, during the DOS days, successfully executed the interrupt vector table with a bogus pointer. Some types of fame I think I can live without...
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
You guys comments gave me a lot of helps!!!!!!!!!!!!!!!!!!
Thankssssssssssssssssssssssssss
|
|
|
|
|
If I have the following code on VB:
Dim myObj as Object
Set myObj = CreateObject("MyDCOMServer.MyClass", "ServerName")
How do I do it on Visual C++?
Thanks a lot,
Julian
|
|
|
|
|
Use this.
HRESULT CoCreateInstanceEx(
REFCLSID rclsid, //CLSID of the object to be created
IUnknown *punkOuter, //the controlling IUnknown
DWORD dwClsCtx, //CLSCTX values
COSERVERINFO *pServerInfo,//Machine on which the object is to be instantiated
ULONG cmq, //Number of MULTI_QI structures in pResults
MULTI_QI *pResults //Array of MULTI_QI structures
);
Cheers,
Anand
|
|
|
|
|
BoundsChecker is giving me the following report for hundreds of occurances within my MFC application.
----
Memory leak
64 bytes allocated by CObject::operator new in wincore.cpp (3941), HANDLE: 0x01C03410
Location of Error
CTempWnd::CreateObject wincore.cpp 3941
The offending function is IMPLEMENT_DYNCREATE which is of course throughout the entire applcation. Is BoundsChecker just wrong here, or is there some cleanup method that I can't seem to find?
Any help appreciated!
A cubicle is just a padded cell without a door.
|
|
|
|
|
Boundschecker is sometimes wrong, and I believe a lot of the 'leaks' in MFC occur on shutdown, when the whole lot of memory is freed anyhow.
Nothing you can do I reckon. You should see all the MFC leaks it gave me when testing a paint program.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Yeah, I turned the MFC suppression stuff on, but this one was the only one that still showed up, and was a significant amount. Most everything else was a one time leak.
It's wrong in some of my stuff as well, I've set a breakpoint on the line where the free or delete happens, seen it execute, written down the memory location and seen BC report it as a leak. Overall it's a great tool, but sometimes it's a little flaky. It seems to be worse with older C code that does malloc/free calls than with new/delete...
Thanks!
Everytime I think I've hit the bottom, someone lends me a shovel.
|
|
|
|
|
Hey there, i know this may sound simple to some but i need some help on getting a string from a text box to a list box. You see i have a button that when pressed, i need to add the value string of the textbox to the listbox. Can someone please help me. Thanx
|
|
|
|
|
this should help, although I have not run it though complier
CString stText;
GetDlgItemText(ID_MYTEXTBOX, stText);
m_lstBox.AddString(stText);
Mike
|
|
|
|
|
Are there any optimization options (or compiler switches) that would decrease amount of memory required by Release build of MFC apps?
I know that memory consumption should be the least concern in these days, but I have small SystemTray app., and it eats quite a bit of RAM. The answer to my problem is to *not* use MFC to write SystemTray application, but writing in C++, would seem bit barbaric.
If there are no optimization options or compiler switches to minimize memory consumption, is there a method that at least would tell Windows OS to use *page file*, while the program is inactive?
thanks in advance
Mike
|
|
|
|
|
Starting at the end, you don't have to *tell* windows to use the page file, it will do so on it's own; not sure what algorithm it uses to determine what blocks to swap out, but i'm sure as long as your program is sitting quietly, it will Do The Right Thing.
If you want to try using something other than MFC, ATL+WTL sounds like it might be a good choice. Don't use it myself though, so can't say for sure.
Finally, a quick-and-easy way to go would be to compile using MFC as a shared library, and use some of the tips given in these articles:
http://www.codeproject.com/tips/reducesixeexe.asp
http://www.codeproject.com/tips/aggressiveoptimize.asp
And if words were wisdom, I'd be talking even more. The Offspring, I Choose
|
|
|
|
|
1. Can you create syntax hilighting for a new filetype?
2. Can you associate a new file extension with as an existing type? (ie .tmpl as an HTML file)
<rant>
1. Its cool that you can save a keyboard scheme but it sucks that you can't do the same for fonts and colors. You have to export the registry settings.
2. You can't have more than 1 row of window tabs (or can you?). Scrolling gets annoying.
3. It seems really slow when you select a filter in help.
4. The HTML editor adds lots of crap to your code.
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
I have created an MDI application whose view is derived from CList. I only have one view and one document. I have used the cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
option to disable the default OnFileNew(). Now I have a application that opens with only a menu. How do I now call my List view(default view) from the mainframe menu? I have added a menu Item, attached a handler to it and tried calling OnFileNew from there. But no List view. Sob. I have read a million msdn files, 2 chapters on MDI applications but still no flashes of intelligence. I'm trying to populate my ListView9defaultview) with items by directly accessing its list control through a call to GetListCtrl() in the OnInitialUpdate() function in my view class. If I take the code populating the control out from OnInitial update, I get a white empty file opening, if I leave it in I get a file with exactly the same grey background as my main window. Am I maybe missing the plot completely? I hope I'm making sense, my brain is so fried it took me 20 minutes to find my office key and leave the building. Please help!
Grasp it but you cannot get it!
It's name is memory..
|
|
|
|
|
Had a cup of tea, am felling calmer so here are more details. The view that I'm trying to call is derived from CListview and is a report style List view showing database information in an Access like gridview.
This is the code I'm using to initialise it
DWORD dwExStyle;
CRepPartDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//CActionsApp *pApp = (CActionsApp*)AfxGetApp();
CListCtrl& m_List = GetListCtrl();
dwExStyle = m_List.GetExStyle();
dwExStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;
m_List.SetExtendedStyle(dwExStyle);
m_List.SetBkColor(RGB(255, 255, 255));
ASSERT(m_List.GetBkColor() == RGB(255, 255, 255));
m_List.InsertColumn(0,_T("Share"),LVCFMT_LEFT,160);
m_List.InsertColumn(1,_T("Status"),LVCFMT_LEFT,90);
m_List.InsertColumn(2,_T("Action Date"),LVCFMT_LEFT,90);
m_List.InsertColumn(3,_T("Book Date"),LVCFMT_LEFT,90);
m_List.InsertColumn(4,_T("Comment"),LVCFMT_LEFT,160);
I have used it before in a SDI application that opened on this view with no problems whatsoever, which leads me to believe there must be a special way of calling the same view from a menu within a MDI application that I'm missing.
This is the only code I have in the menu handler function at the moment
CRepPartApp* pApp = (CRepPartApp*)AfxGetApp();
pApp->m_pDocManager->OnFileNew();
All the example's I can find deals with multiple document and views and switching between them. It is a new job and I'm feeling a bit incompetent so any pointers would be much appreciated
Grasp it but you cannot get it!
It's name is memory..
|
|
|
|
|
I tried a search but didn't find anyone ever asked this question. Is it too simple?
Well, my question is, in my SDI application, on menu item -- action -- I would display a modeless dialog. the code is:
CMyDialog *pdlg;
pdlg = new CMyDialog();
if ( pdlg != NULL )
{
pdlg->Create(IDD_MY_DLG, this);
pdlg->ShowWindow(SW_SHOW);
}
The dialog shows and functions well, but it would be always on the top, even when it lost focus. Is it possible to hide it behind my SDI application when I click on my SDI?
Thank you!
|
|
|
|
|
You may try with changing 2nd parameter in the call to CYourDialog::Create to GetDesktopWindow().
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|