Hi Arnaud,
Thanks for the reply. Essentially the code for transferring the files
works. There's no issue in that.
I have two classes. The main one: Form1 and the secondary thread:
dthread. Essentially the transferring processes all occurs within
dthread. So, once you instantiate dthread in another thread it starts
sending files.
dthread
public:
public: void ThreadCallBack(Object^ threadContext);
The thread starts when it calls: ThreadCallBack in dthread. Via:
MRE[i] = gcnew ManualResetEvent(true);
dthread^ t = gcnew dthread(this->clb_List->Items[a]->ToString(),
MRE[i]);
WTHREAD[i] = t;
System::UInt32^ m_i = gcnew UInt32(i);
//ThreadPool::QueueUserWorkItem(gcnew
System::Threading::WaitCallback(t, &dthread::ThreadCallBack),this);
Thread^ newThread =
gcnew Thread(gcnew ParameterizedThreadStart(t,
&dthread::ThreadCallBack));
ThreadList[i] = newThread;
newThread->Start(this);
break;
You'll notice that this seems to be done to use a ThreadPool. I changed
it to normal threads thinking that would solve the issue. It didn't
seem to be that way. Inside ThreadCallBack we have:
if (ParentThread->InvokeRequired){
IAsyncResult^ A = ParentThread->BeginInvoke(gcnew
GetTextDelegate(this, &dthread::GetTextD));
M = (String^) ParentThread->EndInvoke(A);
}
ParentThread->BeginInvoke(gcnew SetStatusTextDelegate(this,
&dthread::WriteStatusInformation),
(Object^)(gcnew String("Thread: " + _n.ToString() + " Is sending: " +
M->ToString())));
if (!Execute(M)){
ParentThread->BeginInvoke(gcnew SetStatusTextDelegate(this,
&dthread::WriteStatusInformation),
(Object^)(gcnew String("Thread Forced Exit On: " + M + ". Error
Detected.")));
_doneEvent->Set();
return;
}
Execute is where I get the next file to be sent, then continues to loop
while getting files from the list box.
I have two threads. They're created above and placed into an array just
for a way to access them. Both threads hit the point of executing
"GetTextD". The problem is only one continues and attempts to send
files. The first stays there. At least I think it's there.
I was wondering shouldn't they be racing each other? Both attempting to
send files?
> On 4 déc, 22:59, gnas...@gmail.com wrote:
> > Hello,
[quoted text clipped - 18 lines]
> Arnaud
> MVP - VC
gnassar@gmail.com - 05 Dec 2006 22:08 GMT
Update:
I've discovered something interesting.
If the program is set to use 3 threads, two threads can send files, but
one of them is blocked. I can't seem to pinpoint where though.
TIA
gnassar@gmail.com - 05 Dec 2006 22:57 GMT
I've pinpointed the problem:
When I do:
Stream^ loPostData = Request->GetRequestStream();
Within two threads at near close times I assume one fails. Thus killing
the thread. Not sure why but I placed a delay
Thread::Sleep(randobj->next()) it seemed to have fixed the issue
temporarily.
I'm sure thats not the optimal solution.