Hi,
I am using .BeginInvoke to make an asynchronous call to a function, and
passing in a AsyncCallback, so client gets notification when method
completes, relevant code is provided below:
AsyncCallback callback = new AsyncCallback(t his.NotifyIt);
FtpClient ftpC = new FtpClient(FtpSe rver, FtpUserName, FtpPassword);
private void button4_Click_1 (object sender, System.EventArg s e)
{
ftpC.ChangeDir( remotePath);
ftpC.BeginGetFi leSize("test.tx t", callback);
}
//callback function
private void NotifyIt(IAsync Result result)
{
//close connection
ftpC.Close();
MessageBox.Show (result.IsCompl eted.ToString() );
}
//Async Delegate implementation
private delegate Int64 GetFileSizeCall back(String fileName);
public System.IAsyncRe sult BeginGetFileSiz e( String fileName,
System.AsyncCal lback callback )
{
GetFileSizeCall back ftpCallback = new GetFileSizeCall back(this.GetFi leSize);
return ftpCallback.Beg inInvoke(fileNa me, callback);
}
All works great but I can't figure out how to pass in a return value from
GetFileSize which is Int64 to the call back function. Can it be done at all,
or am I on the wrong page all together? 1 8275
Looking at similar things last week I found: http://msdn.microsoft.com/library/de...ngoverview.asp
to be an invaluable resource and even have a printed copy sitting next too me
right now.
When the callback has completed, you would simply capture the return value
from your call to ftpCallback.End Invoke() (which I do not see you using).
Brendan
"Lenn" wrote: Hi,
I am using .BeginInvoke to make an asynchronous call to a function, and passing in a AsyncCallback, so client gets notification when method completes, relevant code is provided below:
AsyncCallback callback = new AsyncCallback(t his.NotifyIt); FtpClient ftpC = new FtpClient(FtpSe rver, FtpUserName, FtpPassword); private void button4_Click_1 (object sender, System.EventArg s e) {
ftpC.ChangeDir( remotePath); ftpC.BeginGetFi leSize("test.tx t", callback);
}
//callback function private void NotifyIt(IAsync Result result) { //close connection ftpC.Close(); MessageBox.Show (result.IsCompl eted.ToString() );
}
//Async Delegate implementation private delegate Int64 GetFileSizeCall back(String fileName); public System.IAsyncRe sult BeginGetFileSiz e( String fileName, System.AsyncCal lback callback ) {
GetFileSizeCall back ftpCallback = new GetFileSizeCall back(this.GetFi leSize); return ftpCallback.Beg inInvoke(fileNa me, callback);
}
All works great but I can't figure out how to pass in a return value from GetFileSize which is Int64 to the call back function. Can it be done at all, or am I on the wrong page all together? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Seeker |
last post by:
Newbie question here...
I have a form with some radio buttons. To verify that at least one of the
buttons was chosen I use the following code ("f" is my form object) :
var btnChosen;
for (count = 0; count <= 1; count++) {
if (eval(f.RadioButtons.checked)) {
btnChosen = true;
}
|
by: Ahmet AKGUN |
last post by:
Hi All;
I have one server to which clients are connected to via TcpChannel.
I start server on one host and establish a client connection from another
host via tcpchannel.
On client, using activators, I try to invoke one function on server side
using channel
After first successfull fucntion invoke, I unplug ethernet cable on server
side...
|
by: Lenn |
last post by:
Hello,
Could you provide specific examples, when one would want to use
AsyncCallback as opposed to just subscribing to events or passing a delegate
to a function? I realize that AsyncCallback is a delegate type, but when it's
absolutely necessary to use it.
Thanks
|
by: Michael Welz |
last post by:
Hello NG,
i try to call a webservice-function with two parameters:
wsfunction(a as AsyncCallback, b as IAsyncResult) as IAsyncResult
The callbackaddress is a simple http-address.
How I define as Datatyp AsyncCallback and IAsyncResult?
|
by: Alper AKCAYOZ |
last post by:
Hello,
I have developped asynchronous socket communication with blocking Socket
commands (accept, connect, send, receive) by using threads on Windows .NET
Forms. It is working properly. Now I want to code the similar program with
Asynchronous Socket commands of .NET using Managed C++ on Windows .NET Forms.
My problem is with delegates. I...
| |
by: darthghandi |
last post by:
I am creating a listener class that listens for incoming connections.
When I get an incoming connection, I want to signal an event to
happen and pass that connected socket to a different thread for the
real work. I want to continue to listen for more connections. So is
the socket I pass with the delegate a reference or a value? I thought...
|
by: Abhi |
last post by:
I wrote a function foo(int arr) and its prototype
is declared as foo(int arr); I modify the values of the array in the
function and the values are getting modified in the main array which
is passed also. I understand that this way of passing the array is by
value and if the prototype is declared as foo(int *), it is by
reference in which case...
|
by: Robert Dailey |
last post by:
Hi,
I noticed in Python all function parameters seem to be passed by
reference. This means that when I modify the value of a variable of a
function, the value of the variable externally from the function is
also modified.
Sometimes I wish to work with "copies", in that when I pass in an
integer variable into a function, I want the...
|
by: lisp9000 |
last post by:
I've read that C allows two ways to pass information between
functions:
o Pass by Value
o Pass by Reference
I was talking to some C programmers and they told me there is no such
thing as pass by reference in C since you are just passing an address
(or a pointer value address I guess?). So I was wondering is this
correct?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |