I have a host that has a method which pops up a MessageBox
the client just activate the function.
it is working but something is weird :
ChannelFactory<IMessagingService> channel = new ChannelFactory<IMessagingService>("NetTcpBinding_IMessagingService");
IMessagingService proxy = channel.CreateChannel();
proxy.Hello("Royi");
if i click on the button in the client many times i see several meesage box ( without closing the last one !!!!!)

but if i change the client code to : ( just by the using mechanism)
ChannelFactory<IMessagingService> channel = null;
using (channel= new ChannelFactory<IMessagingService>("NetTcpBinding_IMessagingService"))
{
IMessagingService proxy = channel.CreateChannel();
proxy.Hello("Royi");
}
and if i try to press many times on the client button – it WONT ALLOW ME !!

this is the code at the host which generates the popup
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerCall)]
public class MessagingService : IMessagingService
{
public void Hello(string message)
{
MessageBox.Show(message);
}
}
i want to understand why
thank you.
First gues (without knowing what the channelfactory does):
Using will call the dispose method after proxy.Hello. The first example uses multiple ChannelFactories next to eachother (till the GC destroys them), while the 2nd always destroyes the ChannelFactory after you print Hello.