private void EndpointTask()
        {
            //Stream readonlystream = null;
            object provider      = null;
            object taskArguments = null;

            try
            {
                try
                {
                    Assembly streamProviderAssembly = Assembly.Load(this.properties.StreamProviderAssemblyName);
                    provider = streamProviderAssembly.CreateInstance(this.properties.StreamProviderTypeName);
                }
                catch (Exception provderException)
                {
                    transportProxy.SetErrorInfo(new ApplicationException("Error creating IScheduledTaskStreamProvider interface", provderException));
                }
                if (provider != null)
                {
                    //create GetStream argument object
                    object [] args   = new object [] {};
                    object    result = provider.GetType().InvokeMember("GetParameterType", BindingFlags.InvokeMethod, null, provider, args);
                    if (result != null)
                    {
                        StringReader  strReader  = new StringReader(this.properties.StreamProviderArguments);
                        XmlSerializer serializer = new XmlSerializer((System.Type)result);
                        taskArguments = serializer.Deserialize(strReader);
                    }
                    //call GetStream
                    args   = new object[] { taskArguments };
                    result = provider.GetType().InvokeMember("GetStream", BindingFlags.InvokeMethod, null, provider, args);

                    if (result != null)
                    {
                        Stream readonlystream = new ReadOnlySeekableStream((Stream)result);

                        IBaseMessageFactory messageFactory = this.transportProxy.GetMessageFactory();
                        IBTTransportBatch   batch          = transportProxy.GetBatch(this, null);

                        IBaseMessage message = this.CreateMessage(messageFactory, readonlystream, this.properties.Name);

                        batch.SubmitMessage(message);
                        batch.Done(null);
                        this.batchFinished.WaitOne();
                    }
                }
            }
            catch (Exception exception)
            {
                string errorMessage = exception.Message;
                //transportProxy.SetErrorInfo(exception);
                while (exception.InnerException != null)
                {
                    exception     = exception.InnerException;
                    errorMessage += "\r\n" + exception.Message;
                }
                transportProxy.ReceiverShuttingdown(this.uri, new ScheduledException(errorMessage));
            }
        }
        private void EndpointTask()
        {
            object provider = null;

            this.adapterConfiguration.Schedule.LastActivated = this.adapterConfiguration.Schedule.NextActivated.Value;
            try
            {
                try
                {
                    provider = this.adapterConfiguration.Task.TaskType.Assembly.CreateInstance(this.adapterConfiguration.Task.TaskType.FullName);
                }
                catch (Exception providerException)
                {
                    transportProxy.SetErrorInfo(new ApplicationException("Error creating ScheduledTaskStreamProvider instance", providerException));
                }
                if (provider != null)
                {
                    if (provider.GetType().GetInterface(typeof(IScheduledTaskStreamProvider).ToString()) != null)
                    {
                        NonTransactionalTask((IScheduledTaskStreamProvider)provider);
                    }
                    else
                    {
                        if (provider.GetType().GetInterface(typeof(IScheduledTaskStreamProvider2).ToString()) != null)
                        {
                            TransactionalTask((IScheduledTaskStreamProvider2)provider);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                string errorMessage = exception.Message;
                //transportProxy.SetErrorInfo(exception);
                while (exception.InnerException != null)
                {
                    exception     = exception.InnerException;
                    errorMessage += "\r\n" + exception.Message;
                }
                transportProxy.ReceiverShuttingdown(this.uri, new ScheduledException(errorMessage));
            }
        }