T
Trecius
Hello, Newsgroupians:
I've yet another question. I have an assembly that provides the interface
for a scanner. The scanner has a method on it called Read(). The prototype
is as follows...
void TheirScannerClass.Read();
To retrieve the information from the scan, I need to add an event to the
created object. EXA:
TheirScannerClass scanner = new TheirScannerCLass();
scanner.ReadEvent += new TheirScannerClass.ReaderReadEvent(SomeMethod);
scanner.Read();
void SomeMethod(ReadEventArgs rea)
{
MessageBox.Show(rea.Value.ToString());
}
So if I executed the above code, the value read would be located in
ReadEventArgs.
I am trying to create a wrapper for TheirScannerClass, for the assembly
architecture is pourly designed. If I create my own method called Read(), I
want the return type to be the ReadEventArgs, which is from the event. For
instance, I'll create a TheirScannerClass as a member of my class. In my
class I'll also create a method called Read, which will return the value
read. The question is how can I return the EVENT'S ReadEventArgs for my
method Read()?
EXA:
class MyScannerClass
{
TheirScannerClass m_scanner;
public MyScannerClass
{
m_scanner = new TheirScannerClass;
m_scanner.ReadEvent += new
TheirScannerClass.ReaderReadEvent(MyScannerClass.ReadEvent);
}
public static void ReadEvent(ReadEventArgs rea)
{
...
}
public static void Read
public string Read()
{
m_scanner.Read();
// Some how have the event's value return here
}
}
I could probably do this using a class variable, but the problem I'd like to
tackle is thread safety. How can I ensure that the value in Read() is for
that specific thread. Thank you, all, for your time and consideration in
this matter.
Trecius
I've yet another question. I have an assembly that provides the interface
for a scanner. The scanner has a method on it called Read(). The prototype
is as follows...
void TheirScannerClass.Read();
To retrieve the information from the scan, I need to add an event to the
created object. EXA:
TheirScannerClass scanner = new TheirScannerCLass();
scanner.ReadEvent += new TheirScannerClass.ReaderReadEvent(SomeMethod);
scanner.Read();
void SomeMethod(ReadEventArgs rea)
{
MessageBox.Show(rea.Value.ToString());
}
So if I executed the above code, the value read would be located in
ReadEventArgs.
I am trying to create a wrapper for TheirScannerClass, for the assembly
architecture is pourly designed. If I create my own method called Read(), I
want the return type to be the ReadEventArgs, which is from the event. For
instance, I'll create a TheirScannerClass as a member of my class. In my
class I'll also create a method called Read, which will return the value
read. The question is how can I return the EVENT'S ReadEventArgs for my
method Read()?
EXA:
class MyScannerClass
{
TheirScannerClass m_scanner;
public MyScannerClass
{
m_scanner = new TheirScannerClass;
m_scanner.ReadEvent += new
TheirScannerClass.ReaderReadEvent(MyScannerClass.ReadEvent);
}
public static void ReadEvent(ReadEventArgs rea)
{
...
}
public static void Read
public string Read()
{
m_scanner.Read();
// Some how have the event's value return here
}
}
I could probably do this using a class variable, but the problem I'd like to
tackle is thread safety. How can I ensure that the value in Read() is for
that specific thread. Thank you, all, for your time and consideration in
this matter.
Trecius