Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in .NET FTP by (700 points)
hi,

I have a form with some controls that displays download statistics. I am using edftpnet to do simultaneous downloads. I also have a my custom ftpconnection class that inherts the ftpconnection class and have inserted some customizations to it. What I do is that I create a loop in which I spawn a new instance of the "DownloadFile" method in my custom class. What I want to do is to update the UI on the main form. So how can I do it? I am getting an error when trying to invoke the updateUI method on the main form using a delegate declared on Form11 and via form1.invoke method. The error is:

ActiveX control 'd27cdb6e-ae6d-11cf-96b8-444553540000' cannot be instantiated because the current thread is not in a single-threaded apartment.
This error is raised in the InitializeComponent of Form1.

So how can I get this to work correctly?

PS: I am using VB 2005 and my application starts with a form no submain is declared.

Thanks

2 Answers

0 votes
by (51.6k points)
Any change you can e-mail us a test project that shows this happening? Please e-mail it to support@enterprisedt.com.

- Hans (EnterpriseDT)
0 votes
by (700 points)
hi,

I resolved the problem by acquiring a handle first to the UI form. I originally by mistake used formname.invoke directly from the worker thread. This is wrong, the correct method is to reference the instance of the UI form using its handle then invoking the delegate like this:

Dim frmUI As frmMain = Application.OpenForms("frmMain")
frmUI.Invoke(New UpdateGUIDelegate(AddressOf frmUI.UpdateUI))


I will send the project to you anyway for inspection.

Am I right?!

Categories

...