|
It seems like a suboptimal design, but besides that you can have >1000 threads/process.
Every thread have a default stack of 1MB reserved address space. If this was the only limiting factor, you could have 2048 threads in a "normal" 2GB user-address-space system, or 3072 threads in a 3GB user-address-space system (please search MSDN for explanations of the 3GB system).
Then every thread (IIRC) uses two pages (i.e. 8KB) just to be started, committing 8MB of memory and...
Why don't you just write a test-app and see how many threads you can start for yourself?
|
|
|
|
|
The server it will be running on will be a minimum of a P3 700 with 128MB of RAM. For the most part the threads will open a database and perform a simple function, then go in to a while loop that checks if a bool is false and if not Sleeps for 1000 milliseconds. I will look in to the thread pool idea. If it's less of a strain it will be the better implementation. Thanks for the tip.
|
|
|
|
|
Out of curiosity I ran a test which created 5k threads which incremented a global counter and then slept for 1000ms. In my main loop I reset the saved the global counter, set it to 0 and then slept for 1000ms.
I have a dual 1.2Ghz with 512mb of ram and I got an average of 2k counts per second.
CThread is my own custom thread class which calls Run in a while loop.
class CMyThread : public CThread
{
public:
CMyThread() {}
int Run()
{
g_Count++;
Sleep(1000);
return 1;
}
};
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
#define numThreads 5000
CMyThread* pThread[numThreads];;
for (int i = 0; i < numThreads; i++)
{
pThread[i] = new CMyThread;
bool bStart = pThread[i]->StartThread();
}
#define numLoops 60
int count = 0;
int total = 0;
for (int j = 0; j < numLoops; j++)
{
g_Count = 0;
Sleep(1000);
total += g_Count;
}
float avg = total / numLoops;
return 0;
}
Todd Smith
|
|
|
|
|
hello!
i have a vc++ MDI programm. in this i need a dialog box. the dialog box is not the problem. my problem is the placing of it. is there a way, how i can place the dialog box in a corner (at the bottom left hand corner) forever and ever.
someone in this forum tells me, that i can use the function: "SetWindowPos"
can somebody give me a example how i can use this function?
Lucky
|
|
|
|
|
If you intend to use standard MessageBox, it is not possible. Instead of this create own dialog and use it as you want
|
|
|
|
|
what must i do, to create a own dialog box?
normally i use the vc++ components.
lucky
|
|
|
|
|
Create Dialog resource, align buttons as you want. In popup menu choose "Add Class". In appeared form choose CDialog as base class. That's all.
If you want use your dialog in Modal mode, use method DoModal, otherwise use
Create()+ShowWindow
|
|
|
|
|
Which parts of SetWindowPos you're having problems with?
Also, do you plan to have a dialog which cannot be moved by the user?
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Yes, the user should not move the dialog, but now i want to say, where there dialog is (at a corner).
i don't understand the complete function
lucky
|
|
|
|
|
If you have problems with SetWindowPos, use MoveWindow instead.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
i used MoveWindow in the OnInitDialog().
MoveWindow( 0, 20, 100, 100, TRUE ); (e.g.)
but nothing happens. i want to define the function in the header, there comes an error. what's wrong?
lucky
|
|
|
|
|
MoveWindow works perfectly for me.
Lucky2002 wrote:
i want to define the function in the header, there comes an error
Which function? MoveWindow? It's already defined in standard headers, otherwise your program wouldn't even compile.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
i don´t know why, but now it works.
but a user can move the dialog. how can i change this?
lucky
|
|
|
|
|
In the dialog editor, remove 'Title' flag in dialog properties. If you want to keep caption bar in your window, then you'll have to override WM_NCHITTEST:
UINT CYourDlg::OnNcHitTest(CPoint point)
{
UINT ret = CDialog::OnNcHitTest(point);
if (HTCAPTION == ret)
{
ret = HTCLIENT;
}
return ret;
}
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
I don´t need the title.....Thank you, functioned greatly !!!!!!!!!!
|
|
|
|
|
try:
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
int x_size = GetSystemMetrics(SM_CXSCREEN);
int y_size = GetSystemMetrics(SM_CYMAXIMIZED);
wp.rcNormalPosition.bottom = y_size;
wp.rcNormalPosition.left = 0;
wp.rcNormalPosition.right = x_size;
wp.rcNormalPosition.top = 0;
wp.showCmd = SW_SHOW;
SetWindowPlacement(&wp);
p.s. Top left corner is (0,0), bottom right is (x_size, y_size)
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Hi,
In a dialog based application, i have two combobox. The cursor is stay in the first combobox when i open the application (with different color in the main dialog window). And also the cursors will put on the two comboboxes when i resize the dialog window. Are these the focus problem?
How to delete these focus?
Thanks in advance
chen
|
|
|
|
|
i need to build an application and it needs to support some languages, how can i do it, how to change from one language to another?
|
|
|
|
|
|
|
Create some resource DLL's (dll that contains only resources without a code) for different languages. Type in CYourApp::InitInstance :
hI=LoadLibrary(....)
AfxSetResourceHandle(hI);
unfortunately switching of language on the fly without application reboot is difficult task since you must recreate all objects (menus, toolbars, dialogs and so on)
|
|
|
|
|
thanks i`ll try that, and what can you suggest me to change them on the fly?
|
|
|
|
|
I can't offer anything more cleverly as something like that example:
for(int i = 0; i < m_arrToolbars.GetSize(); i++) <br />
{ <br />
pToolbar = (CToolBar*)m_arrToolbars[i]; <br />
pToolbar->DestroyWindow(); <br />
delete pToolbar; <br />
}: <br />
<br />
... <br />
<br />
for(i = 0; i < m_arrToolbarIDs.GetSize(); i++) <br />
{ <br />
UINT nID = (UINT)m_arrToolbarIDs[i]; <br />
pToolbar = new CToolBar(); <br />
if (!pToolbar->CreateEx(m_pMainFrame, TBSTYLE_FLAT, WS_CHILD | <br />
CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, <br />
CRect(1,1,1,1), AFX_IDW_TOOLBAR + nID) || <br />
!pToolbar->LoadToolBar(nID)) <br />
{ <br />
TRACE(_T("Failed to create view's toolbar from Resource %d\n"), nID); <br />
delete pToolbar; <br />
continue;
} <br />
ASSERT(::IsWindow(pToolbar->GetSafeHwnd())); <br />
<br />
CString csTitle; <br />
csTitle.LoadString(m_arrToolbarTitleIDs[i]); <br />
pToolbar->SetWindowText(csTitle); <br />
<br />
m_arrToolbars.Add(pToolbar); <br />
}
But it's a very little part of changing interface - only for toolbars. Similarly you should execute such operation for all objects including all dialogs. However why you should make the complications to yourself? It is easier to reboot application
|
|
|
|
|
I need to address the Serial (COM1) port on NT kernel based systems (NT4 and Win2k). I read the articles in the system section, but they don't seem to cover what I'm looking for.
As I want to address some hardware I made myself, I need to have full control. I.E: I must be able to put DTR on high or low at will. The articles here assume baut-rate based comminucations are the way to go.
I'd rather not use the DDK, I don't even have it.
Suggestions? Ideas?
I'm thinking about using the MSCOMM32 ActiveX control, but I'm not too happy with it. I've been looking into ::CreateFile. I can open the com port without trouble, but there isn't functionality for directly reading and writing to the port.
Please help me out,
thanks in advance and kind regards,
Griffith
Everything you say will be misquoted, ripped out of context and used against you.
|
|
|
|
|
After you've opened the port with ::CreateFile you can use ::WriteFile to write to the port. Use ::SetCommState to control the DTR/RTS lines, the baud rate and parity settings via the DCB structure.
If a train station is where the train stops, what's a workstation...?
|
|
|
|