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 6700639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:50:20+00:00 2026-05-26T06:50:20+00:00

What is the best way to implement Gather-Scatter like operation using WCF and C#

  • 0

What is the best way to implement Gather-Scatter like operation using WCF and C# (or F#)?

  1. Lets say that I have 20 nodes (computers) connected by WCF.
  2. Each node computes a time duration value and sends this value to the main node.
  3. The main node takes the minimum value of all the incomming ones and sends this information back to all the nodes.

EDIT:

The resulting code:

open System.ServiceModel
open System.ServiceModel.Channels

let numberOfClients = 10

type IMyContractCallback =
  [<OperationContract>]
  abstract GetDuration: duration: float -> unit

[<ServiceContract(CallbackContract = typeof<IMyContractCallback>)>]
type IMyContract =
    [<OperationContract>]
    abstract SendDuration: duration: float -> unit

[<ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Reentrant)>]
type MyService () =

  let mutable totDuration = 1.
  let callbacks = System.Collections.Generic.Stack ()

  interface IMyContract with
    member o.SendDuration (duration) =
        totDuration <- min totDuration duration
        callbacks.Push (OperationContext.Current.GetCallbackChannel<IMyContractCallback>())
        printfn "N = %d" callbacks.Count
        if callbacks.Count = numberOfClients then
          for c in callbacks do c.GetDuration (totDuration)

  interface IMyContractCallback with
    member o.GetDuration (duration) = printfn "Minimum duration = %g" duration

let address = "net.pipe://localhost/aaa"

let service = MyService ()
let pipe = new NetNamedPipeBinding()

let host = new ServiceHost(service)
host.AddServiceEndpoint(typeof<IMyContract>, pipe, address) |> ignore
host.Open()

for i in 0 .. numberOfClients - 1 do
  let client1 = System.Threading.Thread (fun () ->
    let fact = new DuplexChannelFactory<IMyContract>(new InstanceContext(service), pipe, address)
    let ch = fact.CreateChannel()
    ch.SendDuration (0.4 + float i) )
  client1.Start()
  • 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-05-26T06:50:20+00:00Added an answer on May 26, 2026 at 6:50 am

    You can easily do this with WCF.
    Implement a callback on the client nodes that the server will fire after computing the minimum value.

    See WCF Callbacks; a beginners guide

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

Sidebar

Related Questions

What's the best way to implement an interface that looks like this in rails?
What is the best way to implement a push notification service using RESTful WCF
What is the best way to implement the page view counter like the ones
What's the best way to implement user controls that require AJAX callbacks? I want
Whats the best way to implement rollover 'buttons' like Stackoverflow has for 'Questions', 'Tags',
What's the best way to implement a Hash that can be modified across multiple
What is the best way to implement an interface that combines some instances of
What s the best way to implement a method that creates and assings ID
What's the best way to implement FTP upload and download in PHP? I'm using
What's the best way implement MS SQL full-text search using all the normal things

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.