I HAVE EXPLAINED IT TO MY MAXIMUM CAPACITY.
I am making one app. in which i need to create a seperate access database for each day.
Its a call charging software which monitors the calls made by extensions (just like the hotel rooms).
Now there is GUI, in which there is richtextbox, a treview, and a menustrip.
The treeview shows information about the all the extensions and others.
The user when opens the app can see the treeview on left,richtextbox at bottom and menustrip (at top).
The user can change the nodes when required(and correspondingly the changes are commited to the database)
There is also one "start" button which starts the monitoring.
Now the user can ONLY see the treeview,expand the nodes and scroll the richtextbox when the app. is monitoring (when the start button is clicked) .
They cant change the nodes while the app is monitoring.
For changing they will have to stop it, so that the GUI thread becomes free for not-so-important thing:changing the nodes text (and database)etc because :
There is one serial port component(created at GUI thread) which monitors incoming strings and fetch the data(duration,date,extno. and blah blah) which is very imp (it cant miss even a single incoming string !)
What i am doing is, when the event Data_received of the serial port fires , i create a seperate thread and pass the string as argument(so that the details of teh calls made can be saved in database) so that the GUI thread becomes free and can handle the next incoming string.
Also, the data is stored in a file whose name is same as the day(12/04/08)
I have two main questions :
(1) HOW would I manage the seperate access file for each day?
I can do this:
a)When the app runs for the first time verify that that the database for current day is created or not.(if no create one.)
b)create a thread called DatabaseCreator, which is like this
Expand|Select|Wrap|Line Numbers
- while(true)
- {
- If(today's database not exists)
- create one;
- }
Why i am so desperate the create the database is coz the serial port in GUI thread wants to store the details in today's database !I If it does not find one it will wait till it becoems available (waiting means the next string wont get processed or will be in Queue which i dotn want)
SO this wont work
Expand|Select|Wrap|Line Numbers
- while(true)
- {
- If(today's database not exists)
- create one;
- else
- Thread.sleep(one hour or so)
- /*oops the datareceived cant find the databse for today it's 12:00:01 midnight ! And I last woke up at 11:50 and again slept.I will wake up at 12:50 to check(12:00:00 to 12:50:00 data not stored !)*/
- }
Thanks for ur patience to read it.