I have a method that receives messages from a queue of msmq.
I have 6 different queues in msmq and i d like a single generic method that would receive the messages. THis work, but i need to write 6 methods for each queue. I d like to make it more generic.
public List<QueMessage> getMessagesFromObj1Queue()
{
List<QueMessage> messageList = new List<QueMessage>();
QueObj1 que = new QueObj1();
while (que.ReceiveAll().Count > 0)
{
varmessage = que.Receive(new TimeSpan(0, 1, 0));
messageList.Add(message);
}
return messageList;
}
I have 5 different object which just extends a single abstract class. Below doenst work.
public List<QueMessage> getMessagesFromObj1Queue<T>(T que)
{
List<QueMessage> messageList = new List<QueMessage>();
while (que.ReceiveAll().Count > 0)
{
varmessage = que.Receive(new TimeSpan(0, 1, 0));
messageList.Add(message);
}
return messageList;
}
Above doesnt work
how to fix this?