I have a multithreaded application. I want only one thread to execute my function and other threads in order to pass it during the execution of my function. How can i do this?
My method looks something like this:
public void setOutput(int value) { try { GPOs gpos = reader.Config.GPO; gpos[1].PortState = GPOs.GPO_PORT_STATE.TRUE; gpos[2].PortState = GPOs.GPO_PORT_STATE.TRUE; Thread.Sleep(WAIT); gpos[1].PortState = GPOs.GPO_PORT_STATE.FALSE; gpos[2].PortState = GPOs.GPO_PORT_STATE.FALSE; } catch (Exception ex) { logger.Error("An Exception occure while setting GPO to " + value + " " + ex.Message); } }
source share