I am working on 3 tier architecture: UI, BL, DAL.
In my UI i have following code for Asynchronous page processing:
AddOnPreRenderCompleteAsync(new BeginEventHandler(objAsync_BL.BeginAsyncWork1), new EndEventHandler(objAsync_BL.EndAsyncWork1));
objAsync_BL.BeginAsyncWork1
and
objAsync_BL.EndAsyncWork1
are functions in BL and they call the functions objAsync_DL.BeginAsyncWork1 objAsync_DL.EndAsyncWork1 of DAL.
Now i am collecting an output parameter of type string in EndAsyncWork1 of DAL and i want to return this string to UI. But the problem is that EndAsyncWork1 has return type void; below is the definition of both the functions:
public IAsyncResult BeginAsyncWork1(Object sender, EventArgs e, AsyncCallback cb, object state)
{
open();
op = new SqlParameter("@Result", SqlDbType.VarChar, 50);
op.Direction = ParameterDirection.Output;
cmd = new SqlCommand("fs_check", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pm1 = new SqlParameter();
pm1 = new SqlParameter("@email_id", "abcd");
cmd.Parameters.Add(pm1);
cmd.Parameters.Add(op);
return cmd.BeginExecuteReader(cb, state);
}
public void EndAsyncWork1(IAsyncResult asyncResult)
{
string _emailIdFS = null;
cmd.EndExecuteNonQuery(asyncResult);
_emailIdFS = op.Value.ToString();
return _emailIdFS;
}
When I am changing the return type of EndAsyncWork1 to string, I am getting the following error: (changed in both BL, and DAL)
Error 1 'string BusinessLayer.Async_BL.EndAsyncWork1(System.IAsyncResult)' has the wrong return type
------------------------------------------------------------------------
Also BeginAsyncWork1 accepts following parameter:
(Object sender, EventArgs e, AsyncCallback cb, object state)
I want to pass one more string type to this function like
(Object sender, EventArgs e, AsyncCallback cb, object state, string s)
but it is giving error that
"No overload for 'BeginAsyncWork1' matches delegate 'System.Web.BeginEventHandler' "