Raimund
Hi,
I'm trying to create a C# .NET windows application that uses the SmartFTP .NET interop.
This sample works:
When I call the FTP code from within a new thread, the application crash on the line that access to LastTransferSpeed Value.
This sample works not:
Error in Line "System.NullReferenceException"
Any idea what's going on and how to fix this?
Thanks,
Raimund
I'm trying to create a C# .NET windows application that uses the SmartFTP .NET interop.
This sample works:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace FTPExample
{
public class FTPLib
{
MainForm m_Form;
sfFTPLib.FTPConnectionMTAClass _ftp;
private void OnTransferProgress(int nTransferBytesLo, int nTransferBytesHi)
{
Int64 nTransferBytes = (uint)nTransferBytesLo;
nTransferBytes <<= 32;
nTransferBytes += (uint)nTransferBytesHi;
m_Form.label1.BeginInvoke(m_Form.m_DelegateShowTransferProgress, new Object[] { nTransferBytes.ToString() });
}
public FTPLib(string url, string username, string password, int port, MainForm form)
{
m_Form = form;
sfFTPLib.FTPConnectionMTA _ftp = new sfFTPLib.FTPConnectionMTA();
_ftp.OnTransferProgress += new sfFTPLib.IFTPConnectionEvents_OnTransferProgressEventHandler(OnTransferProgress);
// Host
_ftp.Host = url;
_ftp.Port = port;
_ftp.Username = username;
_ftp.Password = password;
_ftp.Passive = true;
_ftp.Timeout = 60000;
...
When I call the FTP code from within a new thread, the application crash on the line that access to LastTransferSpeed Value.
This sample works not:
private void OnTransferProgress(int nTransferBytesLo, int nTransferBytesHi)
{
Int64 nTransferBytes = (uint)nTransferBytesLo;
nTransferBytes <<= 32;
nTransferBytes += (uint)nTransferBytesHi;
int TransferSpeed = _ftp.LastTransferSpeed; // <---- crash here
m_Form.label1.BeginInvoke(m_Form.m_DelegateShowTransferProgress, new Object[] { nTransferBytes.ToString() });
}
Any idea what's going on and how to fix this?
Thanks,
Raimund