There are multiple Add and delete buttons on the local GUI. Once I click on the add/delete button from GUI then I am getting button active button IDs in the form of array through the “mainHandler” handler.
Then I am extracting each ID from array and do some processing. The processing should continue periodically (lets say every 60 seconds) for each ID. This will be for infinite time.
Once I click on Add/Delete button then again I will get complete list of all active IDs again and I need to do processing only on those IDs. But sometimes the main thread is not getting called when I add/delete list from local GUI.
If I comment go c.func1() function then I am able to receive data every time in the handler if it is updated from local GUI.
Code Snippet:
type DataTable struct {
Exit chan struct{}
DataList []string
}
var dataTable *DataTable
func (c *controller) mainHandler(mc xxxx) {
if dataTable == nil {
dataTable = &DataTable{}
} else {
dataTable.Exit <- struct{}{}
}
r := mc.BodyReader()
dataTable.DataList = r.GetSliceOfString(“data”) // Updating IDs in the slice
go c.func1()
}
func (c *controller) func1() {
for {
select {
case <-time.After(60 * time.Second):
c.func2() // The processing will be done on dataTable.DataList inside this function. Sometimes this function took 10 seconds to complete the opration.
case <-dataTable.Exit:
return
}
}
}