|
도움말 파일에 보니까 리턴값이 -1이면 errno라는 글로벌 변수값으로 에러 이유가 나온다네요..?
도움말:
_beginthread returns the handle of the new thread. The return value is a standard Windows handle that can be used in operating system API's such as SuspendThread and ResumeThread.
On error, the function returns -1, and the global variable errno is set to one of the following values:
EAGAIN Too many threads
EINVAL Invalid stack size (i.e. less than 16 bytes, or equal to zero)
ENOMEM Not enough memory
Also see the description of the Win32 API GetLastError, in the MSDN Library.
임세환 님이 쓰신 글 :
: 구조는 아래처럼 되어 있습니다.
: 설명드리면 mainForm에서 subForm을 동적으로 여러개 만들수 있고 이 subForm은 mainForm이
: 동작하는걸 방해하지 않기 위해 쓰레드를 생성해서 할려고 합니다.
: ====================================================================================
: MainForm --> 다수의 subForm 동적 생성 --> ButtonClick시에 1개의 쓰레드를 생성하는 구조입니다.
:
:
: 그런데 mainForm에서 생성한 subForm이 갖는 컴포넌트들이나 ShowMessage등의
: 일반적인 컨트롤은 매우 정상적이고 잘됩니다. 여러개가 띄우는것도..
:
: 근데 정작 중요한 쓰레드 생성에서 먹통이 되어서 어떻게 해야 할지 몰라 질문드립니다.
: 아래 소스를 참조하시고 도움을 주시면 고맙겠습니다.
: 질문의 요지는 subForm내에서 왜 버튼Click시 쓰레드를 만들지 못하는가 입니당..
:
:
:
:
:
: MainForm::트리의 일부를 Click할때..
: ====================================
: if (TreeView1->Selected->Parent != NULL && TreeView1->Selected->Parent->Text == "Tables")
: {
: TForm7 *form7 = new TForm7(this);
:
: form7->Edit4->Text = "";
: form7->Edit5->Text = "";
: form7->Edit6->Text = "";
: form7->Edit4->Text = TreeView1->Selected->Parent->Parent->Parent->Text;
: form7->Edit5->Text = TreeView1->Selected->Parent->Parent->Text;
: form7->Edit6->Text = TreeView1->Selected->Text;
:
:
: form7->Show();
: }
:
:
: SubForm::쓰레드를 생성할때..
: =======================================
: void __fastcall TForm7::Button1Click(TObject *Sender)
: {
: HANDLE handle;
: int val = 0;
:
: if (Edit1->Text.Length() == 0) {
: ShowMessage("Check Column delimeter !!");
: return ;
: }
: if (Edit2->Text.Length() == 0) {
: ShowMessage("Check Row delimeter !!");
: return ;
: }
: if (Edit3->Text.Length() == 0) {
: ShowMessage("Check FileName !!");
: return ;
: }
:
: // 이부분이 죽어라 안됩니당... ㅠ.ㅠ
: handle = (HANDLE) _beginthread( backGround, 0, &val); // create thread
: if (handle == NULL) {
: ShowMessage("_beginThread Fail!!");
: Form7->Close();
: }
: //WaitForSingleObject(handle,INFINITE);
: //Form7->Close();
:
: }
:
:
: 쓰레드함수
: ============================================
: void backGround(void* lParam)
: {
: SQLHENV env = SQL_NULL_HENV;
: SQLHDBC dbc = SQL_NULL_HDBC;
: ...
: 이하 생략..
:
: _endthread();
: }
|