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 TheirScannerCla ss.Read();
To retrieve the information from the scan, I need to add an event to the
created object. EXA:
TheirScannerCla ss scanner = new TheirScannerCLa ss();
scanner.ReadEve nt += new TheirScannerCla ss.ReaderReadEv ent(SomeMethod) ;
scanner.Read();
void SomeMethod(Read EventArgs rea)
{
MessageBox.Show (rea.Value.ToSt ring());
}
So if I executed the above code, the value read would be located in
ReadEventArgs.
I am trying to create a wrapper for TheirScannerCla ss, 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 TheirScannerCla ss 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
{
TheirScannerCla ss m_scanner;
public MyScannerClass
{
m_scanner = new TheirScannerCla ss;
m_scanner.ReadE vent += new
TheirScannerCla ss.ReaderReadEv ent(MyScannerCl ass.ReadEvent);
}
public static void ReadEvent(ReadE ventArgs 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 TheirScannerCla ss.Read();
To retrieve the information from the scan, I need to add an event to the
created object. EXA:
TheirScannerCla ss scanner = new TheirScannerCLa ss();
scanner.ReadEve nt += new TheirScannerCla ss.ReaderReadEv ent(SomeMethod) ;
scanner.Read();
void SomeMethod(Read EventArgs rea)
{
MessageBox.Show (rea.Value.ToSt ring());
}
So if I executed the above code, the value read would be located in
ReadEventArgs.
I am trying to create a wrapper for TheirScannerCla ss, 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 TheirScannerCla ss 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
{
TheirScannerCla ss m_scanner;
public MyScannerClass
{
m_scanner = new TheirScannerCla ss;
m_scanner.ReadE vent += new
TheirScannerCla ss.ReaderReadEv ent(MyScannerCl ass.ReadEvent);
}
public static void ReadEvent(ReadE ventArgs 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
Comment