Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in .NET FTP by (260 points)
Hello EDT;

I am experimenting with edtFTP free for .NET; I create multiple instances of the FTPConnection object to upload files to different servers simultaneously. I expected to be able to use the argument instance variables in the Connected event handler and BytesTransferred event handler called e.instanceNumber and/or e.taskID to figure out which instance of the FTPConnection triggered the event handler.

There is a problem however both e.instanceNumber and e.taskID = a -1 when the event is called? I can't find any documentation at all on these but it seems like they are there so I can figure out which instance of the FTPConnection triggered the even when you have multiple instances?

How can I find out which instance triggered events such as BytesTransferred or Connected events when I create and start multiple instances of FTPConnection?

Thanks
Neal Davis

4 Answers

0 votes
by (162k points)
Can't you use the sender of the event?
0 votes
by (260 points)
I'm not certain how to use the sender to distinguish between FTPConnection instances?

I basically create multiple instances like this:

foreach(var item in dgView.Rows) {

FTPConnection ftp = new FTPConnection();
//then I create the ftp events for BytesTransferred, Connected, Uploaded...

}

all instances of ftp use the same event handler for BytesTransferred, Connected, Uploaded...

So how do I use the sender object argument to distinguish which ftp instances caused the event?

Isn't that what you guys have the e.InstanceNumber and possible e.TaskID for? However as I said those are always -1?

Neal Davis
0 votes
by (162k points)
Are you sure the InstanceNumber is -1?

If you look at the constructor, you'll see this code:

            lock (instanceCountMutex)
            {
                this.instanceNumber = instanceCount++;
            }


The instanceCount static variable starts at 0, and is only incremented.

Try debugging the code to see how it gets set.
0 votes
by (260 points)
Hi Bruce;

So far all I have seen when I look at e.instanceNumber is -1 I'll attempt some more debugging on this as I would really like to use e.instanceNumber it would be ideal.

I am attempting to use a work around right now by assigning the FTPConnection instance variable "Name" a value of 1 to n for each instance I start this may be working for me until I figure out the deal with e.instanceNumber.

I'll keep you posted or if you get a chance to test this at your end let me know what you see?

Thanks
Neal Davis

Categories

...