Updating status bar from a class library

V

Venu

Hi Everyone,

I'm very new to C# and I have the following problem - please help.

I have a Windows Forms application called 'FunApp' which has a status
bar. I also have a separate class library called FunTx compiled as a
DLL.

What I want to do is update the status bar from within a FunTx method -
and I used delegates to try this. Here's what I did.

FunApp
--------
delegate void SetStatusBar(void)

in a method of FunApp, I instantiated this

SetStatusBar sb = new SetStatusBar(SetStatusbarText);
where SetStatusBarText is a method that sets the .Text property of the
status bar.

I do the usual stuff like
FunTx ft = new FunTx();
ft.FunProcess(sb,n);

FunTx (separate class library - DLL)
-----
in FunTx I have a method called FunProcess

public void FunProcess(SetStatusBar sb, int y)
{
.....do something....
sb("And now update the status bar");
}


But nothing happens. No change in status bar. What am I doing wrong?
Any help (other ways to do too) is greatly appreciated.

thanks!
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

Your delegate seem to accept no parameters. How do you expect FunTx to pass
the updated message to be displayed on the status bar?

This line:
sb("And now update the status bar");

should upset the compiler!
 
V

Venu

Dmitriy Lapshin said:
Hi,

Your delegate seem to accept no parameters. How do you expect FunTx to pass
the updated message to be displayed on the status bar?

This line:


should upset the compiler!


Hi Dmitriy,
Yes it did :) (after I posted the Q) because I was mistakenly not
compiling my class library. Anyway, now I'm lost - I don't know how to
do this. Is there some way I can accomplish this thru my class
library?

-v

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Venu said:
Hi Everyone,

I'm very new to C# and I have the following problem - please help.

I have a Windows Forms application called 'FunApp' which has a status
bar. I also have a separate class library called FunTx compiled as a
DLL.

What I want to do is update the status bar from within a FunTx method -
and I used delegates to try this. Here's what I did.

FunApp
--------
delegate void SetStatusBar(void)

in a method of FunApp, I instantiated this

SetStatusBar sb = new SetStatusBar(SetStatusbarText);
where SetStatusBarText is a method that sets the .Text property of the
status bar.

I do the usual stuff like
FunTx ft = new FunTx();
ft.FunProcess(sb,n);

FunTx (separate class library - DLL)
-----
in FunTx I have a method called FunProcess

public void FunProcess(SetStatusBar sb, int y)
{
....do something....
sb("And now update the status bar");
}


But nothing happens. No change in status bar. What am I doing wrong?
Any help (other ways to do too) is greatly appreciated.

thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top