开发者

Moving data around classes and a GUI

My program moves files from one folder to another immediately upon creation. The files will be coming in by about 50 per second. The program monitors two folders and sends files in those two folders to certain directories on the computer.

The one thing I want to get sorted out is the errors that could potentially pop up. I thought about using messagebox.show to let the user know lets say "the folder does not exist," but with 10000 or so files unable to be moved, or if access to directories is denied, the computer might just run out of memory with 10000 popups.

An alternative is simply to display a message to the user on the GUI control, and stop the file watcher. The problem is, my folderwatcher class cannot access the status bar in my GUI. So if the status bar was called messages, I cannot simply assign "messages.text" to the error message from the exception thrown in the folderwatcher class.

I was also told that it is bad practice to give the control on the GUI to the folderwatcher class as it defeats the purpose of object oriented programming. (something along those lines).

So, I thought about constructing a class that simply stores data/status messages. My GUI will hook in to that class and the folderwatcher class will upda开发者_Go百科te it when an error occurs. When that happens, my GUI will update and the messages.text will show the error for the user to see.

I think this concept will work quite well, but I'm not sure where to start. If you need any additional information I'll be happy to provide, but feedback and hints/tips are what I'm looking for.

Also, is my method of constructing a separate class holding information the best method to transferr error messages between the class and GUI? or is there an easier way to do it?

Sincerely,

tf.rz. Thanks for your help! It is greatly appreciated.


Build a private method with strings with different values and when an Error Pops, Just Get and Set the Value to the Appropriate Messagebox. Which could be assigned as a global variable.


I've hooked the class and the GUI via another class which contains just one string and an event handler. The GUI subscribes to the event handler and the class will create an instance of the new class created and modify the string. When the string changes, the GUI will be updated and the user will then see the message. Thank you to all who contributed!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜