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?
ad******@club-internet.fr wrote:
On 4 déc, 22:59, gnas...@gmail.com wrote:
Hello,
I have created a program that utilizes three threads minimum. The
initial gui thread, and two worker threads. I haven't set the worker
threads as background threads yet. The problem I am facing is that each
thread when opened initialized itself and begins sending a file to a
server on my network.
Essentially I'd like to transfer two files at the same time to a single
place. The only problem I'm facing is that after one starts, the other
file essentially stops sending. The thread doesn't continue processing.
Actually it does nothing.
What do you mean by "a single place". Do you mean you want to copy 2
fines in the same network directory?
How are you "sending" the files? Give us more details, or show us a
minimum code sample.
Arnaud
MVP - VC