Majid Bhutta

Majid Bhutta

  • NA
  • 10
  • 0

Synchronization Required?

Dec 7 2005 12:10 AM

well here is the description of my problem
I have a component in which all the methods are static let
the skeleton is like below

public Class Component
{
.............
.........
.......

public static void St_F1(--,--,--)
{
---  -
---
--
}

public static void St_F2(--,--,--)
{
---  -
---
--
}

public static void St_F3(--,--)
{
---  -
---
--
}

public static void St_F4(--)
{
---  -
---
--
}


}

  //////////////////
now these functions are called in other class MyClass in
the delegate MyDlg that is called when the Capture event
occurs
public Class MyClass
{
----
----
private Scanner myobj=new Scanner();

myobj.Capture+=new CaptureEventHandler(MyDlg);

private void MyDlg(---,--,---)
{
Componet.St_F4(--);

Componet.St_F1(--,--,---);

if(myobj.id==1)
Componet.St_F3(---,--);

if(myobj.id==2)
Componet.St_F2(--,--);

}

}


 ////////////////////////

Now i make 2 objects of MyClass each of them has a unique

value of myobj.id
MyClass ClassObj1=new MyClass();
MyClass ClassObj2=new MyClass();

Now both of these instances of the MyClass have to call
event myobj.Capture+=new CaptureEventHandler(MyDlg);
implicitly nad may be event occurs from both objects at a time i want to make the call to the each Static Function called in the body of MyDlg  synchronized. So as Only one object may call the Static function at a time. How to achieve this. Plz help Me

Thnx in Advance