Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Asynchronous methods - callback method is never called

Asynchronous methods - callback method is never called

Scheduled Pinned Locked Moved C#
helpvisual-studiosysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lvq684
    wrote on last edited by
    #1

    Hi. I have this console based Asynchronous VS project that works fine. And then i have a remoting project which also works fine. I want to edit the remoting project so it is non-blocking, using asynchronous calls. I´ve tried different examples, but I cant get it to work. None of them seems to call my callback method back. Here is the relevant snippets: The remote object:

    ....
    public class MultiContainer : MarshalByRefObject, IMultiContainer
    {
    public string GetClientsList()
    {
    Thread.Sleep(1000);
    return Program.ServerForm.GetClientsList();
    }
    ....

    The client which accesses the remote object with asyn call:

    namespace Client
    {
    public partial class Form1 : Form
    {
    Server.IMultiContainer mc;
    private delegate string Delegate();

        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1\_Click(object sender, EventArgs e)
        {
            mc = new Server.MultiContainer();
            Delegate del = new Delegate(mc.GetClientsList);
            AsyncCallback callback = new AsyncCallback(Callback);
            del.BeginInvoke(callback, null);
        }
    
        private void Callback(IAsyncResult ar)
        {
            //this callback method is never called...
            Delegate del = (Delegate)((AsyncResult)ar).AsyncDelegate;
            richTextBox1.Text = del.EndInvoke(ar);
        }
    

    ...

    Been sitting with this problem for hours, hope you can help! Thanks alot :)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups