Hidden Folder - UI Thread

Hi,

Is there a way to lock a folder from being open in a URCap? I am looking at creating a folder that is locked. When I try to create a thread to prevent the folder from being opened I get an error for UI objects only can be updated within the UI thread.

Is it possible to update the UI thread constantly to set the folder hidden to true?