0

Hi,


I have made a DLL coded in C#, and and executable in C#. I've already have the DLL referenced in my Exe project, so i cannot reference the DLL back to the Exe because it won't let me. Now what I need to do is, call a function within the Exe project from the DLL. Really what I want to do is, empty out a Rich Text Box field, in my form inside the Exe project, from the DLL file.

Any help?

I was thinking of making a pointer in the DLL file, and a timer in my Exe Project, and when the pointer's value returns 1 then it empties the RTB, and sets the pointer to 0.

But I don't know how to do that.... I know how to create the pointer, but don't know how to retrieve it in the Exe.

Please help!! ~ THANKS!!

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by kashn
1

Use an interface or a delegate. Here is an interface example:

.EXE Application

using System;
using System.Windows.Forms;
using daniweb.callbackDLL;

namespace daniweb
{
  public partial class FormCallback : Form, IClearTextBox
  {
    public FormCallback()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      CallbackDLL.DoWork(); //this will clear the textbox
    }

    private void FormCallback_Load(object sender, EventArgs e)
    {
      CallbackDLL.RegisterCallback(this);
    }

    #region IClearTextBox Members
    void IClearTextBox.ClearTextBox()
    {
      textBox1.Text = string.Empty;
    }
    #endregion
  }
}

DLL Application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace daniweb.callbackDLL
{
  public interface IClearTextBox
  {
    void ClearTextBox();
  }

  public static class CallbackDLL
  {
    private static IClearTextBox _callback;
    public static void RegisterCallback(IClearTextBox Callback)
    {
      _callback = Callback;
    }
    public static void DoWork()
    {
      //do whatever
      _callback.ClearTextBox();
      //do whatever else
    }
  }
}
Votes + Comments
OMG.. Your the best! :D
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.