Interesting problem. If I understand your requirements, you need to allow the user to continue about their business while the report is being generated in the background, then finally send notification to the user that the report is ready via AJAX.
I believe you are heading in the right direction. What I'd suggest is to leverage WCF asynchronous callback. A good starter article on MSDN is available here. The callback event handler should set a cached status of the report using a unique cache key created when the report request is initially sent to the WCF operation.
Client-side notification can be achieved using a report status polling mechanism which periodically checks the status of the report using the same unique cache key enabled by AJAX.
A simple example of the asynchronous WCF callback could do something such as the following:
ReportServiceClient reportSvcClient = new ReportServiceClient();
Guid reportStatusKey = Guid.NewGuid();
reportSvcClient.GenerateReportCompleted += new EventHandler<GenerateReportCompletedEventArgs>(ReportStatusCallback);
reportSvcClient.GenerateReportAsync(reportStatusKey, <other operation paramters>);
// Set initial report status to False
// (recommend setting an appropriate expiration period)
Cache.Insert(reportStatusKey.ToString(), false);
// WCF callback static method which sets the report status in cache
static void ReportStatusCallback(object sender, GenerateReportCompletedEventArgs e)
{
Cache[e.ReportStatusKey.ToString()] = e.IsComplete;
}
...
public partial class GenerateReportCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{
private object[] results;
public GenerateReportCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState)
{ this.results = results; }
public Guid ReportStatusKey
{
get {
base.RaiseExceptionIfNecessary();
return ((Guid)(this.results[0]));
}
}
public bool IsComplete
{
get {
base.RaiseExceptionIfNecessary();
return ((bool)(this.results[1]));
}
}
}
The client-side AJAX implementation can check the cached status of the report at whatever frequency you believe is appropriate by using the same ReportStatusKey.