Click here to Skip to main content
15,890,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: C # Pin
OriginalGriff31-May-15 2:47
mveOriginalGriff31-May-15 2:47 
AnswerRe: C # Pin
Abhipal Singh31-May-15 2:53
professionalAbhipal Singh31-May-15 2:53 
AnswerRe: C # Pin
Ravi Bhavnani1-Jun-15 5:36
professionalRavi Bhavnani1-Jun-15 5:36 
JokeRe: C # Pin
Richard Deeming1-Jun-15 8:47
mveRichard Deeming1-Jun-15 8:47 
GeneralRe: C # Pin
Ravi Bhavnani1-Jun-15 8:56
professionalRavi Bhavnani1-Jun-15 8:56 
QuestionAction<T> Delegate usage between 2 applications Pin
Member 1171394230-May-15 23:01
Member 1171394230-May-15 23:01 
AnswerRe: Action<T> Delegate usage between 2 applications Pin
Richard MacCutchan31-May-15 1:11
mveRichard MacCutchan31-May-15 1:11 
AnswerRe: Action<T> Delegate usage between 2 applications Pin
BillWoodruff31-May-15 1:55
professionalBillWoodruff31-May-15 1:55 
You do realize that an Action<T> is a full-featured multi-cast delegate ? Outside "consumers" of an object-instance which offers access-to/exposes the Action can subscribe to it using += or directly assign to it.

I like using a strategy where a Property "slot" for a Public Action<T> is declared in one class (in your case the dll), and then another class (the consumer of the first class/dll) injects a reference to a valid method/lambda/delegate that matches the signature:
C#
// in the 'dll
public Action<string> PrintJobDone { set; get; }

// method that gets an update on job status
private void PrintJobUpdate(bool jobdone, string currentjobname, int jobnumber, int jobslefttodo)
{
    // do some stuff ?

    if (jobdone && PrintJobDone != null) // handle jobdone == false, or PrintJobDone == null ?
    {
        PrintJobDone(string.Format("job completed: {0} / job#: {1} / jobslefttodo: {2}", currentjobname, jobnumber, jobslefttodo));
    }

    // do more stuff ?
}
In a consuming Form or object with a reference to your 'dll:
C#
private void Form1_Load(object sender, EventArgs e)
{
    yourDllInstance.PrintJobDone = printJobCallBack;
}

private void printJobCallBack(string msg)
{
   // display message to user
}

«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.


modified 31-May-15 8:13am.

GeneralRe: Action<T> Delegate usage between 2 applications Pin
Member 1171394221-Jun-15 6:05
Member 1171394221-Jun-15 6:05 
AnswerRe: Action<T> Delegate usage between 2 applications Pin
Armugam Indrani31-May-15 19:40
professionalArmugam Indrani31-May-15 19:40 
GeneralRe: Action<T> Delegate usage between 2 applications Pin
Member 1171394221-Jun-15 6:01
Member 1171394221-Jun-15 6:01 
GeneralRe: Action<T> Delegate usage between 2 applications Pin
Member 1171394229-Jun-15 20:26
Member 1171394229-Jun-15 20:26 
AnswerRe: Action<T> Delegate usage between 2 applications Pin
HaldorPhil20-Aug-15 6:57
HaldorPhil20-Aug-15 6:57 
Question[SOLVED] SQL Server 2014 & SqlDataSourceEnumerator Pin
MooKowMyke30-May-15 19:14
MooKowMyke30-May-15 19:14 
AnswerRe: SQL Server 2014 & SqlDataSourceEnumerator Pin
MooKowMyke30-May-15 20:37
MooKowMyke30-May-15 20:37 
AnswerRe: SQL Server 2014 & SqlDataSourceEnumerator Pin
Eddy Vluggen31-May-15 0:52
professionalEddy Vluggen31-May-15 0:52 
GeneralRe: SQL Server 2014 & SqlDataSourceEnumerator Pin
MooKowMyke31-May-15 17:20
MooKowMyke31-May-15 17:20 
QuestionHow to change datatype of a variable without changing its value ? Pin
Member 968349129-May-15 22:14
Member 968349129-May-15 22:14 
AnswerRe: How to change datatype of a variable without changing its value ? Pin
OriginalGriff29-May-15 22:59
mveOriginalGriff29-May-15 22:59 
QuestionNot able to insert my data into sql db. Getting that annoying null error! Pin
Norris Chappell29-May-15 7:15
Norris Chappell29-May-15 7:15 
AnswerRe: Not able to insert my data into sql db. Getting that annoying null error! Pin
Richard Deeming29-May-15 7:41
mveRichard Deeming29-May-15 7:41 
AnswerRe: Not able to insert my data into sql db. Getting that annoying null error! Pin
Sascha Lefèvre29-May-15 7:48
professionalSascha Lefèvre29-May-15 7:48 
GeneralRe: Not able to insert my data into sql db. Getting that annoying null error! Pin
Norris Chappell29-May-15 8:14
Norris Chappell29-May-15 8:14 
GeneralRe: Not able to insert my data into sql db. Getting that annoying null error! Pin
Sascha Lefèvre29-May-15 12:33
professionalSascha Lefèvre29-May-15 12:33 
GeneralRe: Not able to insert my data into sql db. Getting that annoying null error! Pin
Norris Chappell31-May-15 8:41
Norris Chappell31-May-15 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.