G
Guest
I have a derived class from the Queue base class. I need it to be
thread-safe, so I am using the Synchronized method (among other things out of
scope of this issue). The code below compiles, but at runtime, the cast of
"Queue.Synchronized(new EventQueue())" to an EventQueue object is failing
stating invalid cast.
Why?
public class EventQueue : System.Collections.Queue { ... }
public class AnotherClass {
private static EventQueue q = null;
public void AnotherMethod() {
q = (EventQueue)Queue.Synchronized(new EventQueue());
}
}
thread-safe, so I am using the Synchronized method (among other things out of
scope of this issue). The code below compiles, but at runtime, the cast of
"Queue.Synchronized(new EventQueue())" to an EventQueue object is failing
stating invalid cast.
Why?
public class EventQueue : System.Collections.Queue { ... }
public class AnotherClass {
private static EventQueue q = null;
public void AnotherMethod() {
q = (EventQueue)Queue.Synchronized(new EventQueue());
}
}