Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7923615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:22:55+00:00 2026-06-03T17:22:55+00:00

I have an ASP.NET 3.5 app consuming a C# WCF in an intranet. The

  • 0

I have an ASP.NET 3.5 app consuming a C# WCF in an intranet.

The service executes three commands sequentially taking 2-3 mins each. I’d like to keep the user updated with the command that is running, for example, refreshing a label.

I’m not an expert on this matter so I’d like to know what is the best way to do this.

Thanks,

Ps. The service and the client are hosted in the same server using IIS 7.5.

EDIT

Well, I’ve been working on this for the past two days .. I’m not an expert 🙂

I’m following Eric’s suggestion, use of WSHttpDualBinding and a callback function.

So, I was able to build a service using duplex binding and define a callback function, however I can’t define the callback function on the client side, can you please shed some light on this.

namespace WCF_DuplexContracts
{
    [DataContract]
    public class Command
    {
        [DataMember]
        public int Id;
        [DataMember]
        public string Comments;
    }



    [ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(ICallbacks))]
    public interface ICommandService
    {
        [OperationContract]
        string ExecuteAllCommands(Command command);
    }

    public interface ICallbacks
    {
        [OperationContract(IsOneWay = true)]
        void MyCallbackFunction(string callbackValue);
    }



    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class CommandService : ICommandService
    {
        public string ExecuteAllCommands(Command command)
        {
            CmdOne();
            //How call my callback function here to update the client??
            CmdTwo();
            //How call my callback function here to update the client??
            CmdThree();
            //How call my callback function here to update the client??

            return "all commands have finished!";
        }

        private void CmdOne()
        {
            Thread.Sleep(1);
        }

        private void CmdTwo()
        {
            Thread.Sleep(2);
        }

        private void CmdThree()
        {
            Thread.Sleep(3);
        }
    }
}

EDIT 2

This the client implementation,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Client.DuplexServiceReference;
using System.ServiceModel;

namespace Client
{
    class Program
    {
        public class Callback : ICommandServiceCallback
        {
            public void MyCallbackFunction(string callbackValue)
            {
                Console.WriteLine(callbackValue);
            }
        }

        static void Main(string[] args)
        {
            InstanceContext ins = new InstanceContext(new Callback());
            CommandServiceClient client = new CommandServiceClient(ins);

            Command command = new Command();
            command.Comments = "this a test";
            command.Id = 5;

            string Result = client.ExecuteAllCommands(command);
            Console.WriteLine(Result);

        }
    }
}

And the result:

C:\>client
cmdOne is running
cmdTwo is running
cmdThree is running
all commands have finished!
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:22:56+00:00Added an answer on June 3, 2026 at 5:22 pm

    Use a duplex binding and update status in a callback.

    EDIT*
    You need to get a reference to the callback channel

    public string ExecuteAllCommands(Command command)
        {
    
            var callback = OperationContext.Current.GetCallbackChannel<ICallbacks>();                  
            CmdOne();
            //How call my callback function here to update the client??
            callback.MyCallbackFunctio("cmdOne done");
            CmdTwo();
            callback.MyCallbackFunctio("cmdTwo done");
            //How call my callback function here to update the client??
            CmdThree();
            callback.MyCallbackFunctio("cmdThree done");
            //How call my callback function here to update the client??
    
            return "all commands have finished!";
        }
    

    You’ll prolly want the service method to be void as to not time out

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET app that sits on our intranet, using the WindowsIdentity to
I have an ASP.NET MVC app and I want to add to each page
I have an ASP.NET app with a three layer architecture: Presentation layer: ASP.NET Bussiness
I have an ASP.NET app that gets its data form an external service, via
I have an ASP.NET app (it uses DevExpress v 10.2). There is a button
I have an asp.net app that uses System.IO.Path.GetTempFileName() for temporary files. In the production
What way makes the most sense? I have a ASP.NET app... and maybe a
Have an ASP.net web app which works fine for a few days, but then
I have an asp.net web app. I want to separate out a particular section
I have an ASP.NET MVC3 app and when the user clicks on my anchor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.