Answered by:
how to get systemstatus in background

Question
-
Hi,
private void Form1_Load(object sender, EventArgs e) { SystemState activesyncState = new SystemState(SystemProperty.ActiveSyncStatus); activesyncState.Changed += new ChangeEventHandler(activesyncState_Changed); } void activesyncState_Changed(object sender, ChangeEventArgs args) { status = (ActiveSyncStatus)args.NewValue; if (status.Equals(ActiveSyncStatus.Synchronizing)) { MessageBox.Show("Sync"); // <-Do not work } } My application download file after sync with ActiveSyncIt works fine in foreground modebut it dosen't work in background mode(using 'this.Hide()')Application can't get SystemState event if visible is false..Monday, March 2, 2009 5:49 AM
Answers
-
Hi Kevin,
Please try the following. I tested the following. Its working perfectly both in foreground and background mode. Arralist is not required actually. but It was working when I added arraylist. So you try with out arraylist, if not use the code as it is.
private
void button1_Click(object sender, EventArgs e){
this.Hide();}
private ArrayList stateList = new ArrayList(); ActiveSyncStatus syncStatus; private void Form1_Load(object sender, EventArgs e){
SystemState s = new SystemState(SystemProperty.ActiveSyncStatus);s.Changed +=
new ChangeEventHandler(ActiveSyncchanged);stateList.Add(s);
}
private void ActiveSyncchanged(object sender, ChangeEventArgs args){
syncStatus = (
ActiveSyncStatus)args.NewValue; if (syncStatus.Equals(ActiveSyncStatus.Synchronizing)){
MessageBox.Show("Synching");}
}
Please let me know if my code is not solving your problem.
Regards,
Malleswar- Proposed as answer by Malleswara Reddy [MCTS, MCP] Tuesday, March 3, 2009 2:48 PM
- Marked as answer by Kevin Cho Wednesday, March 4, 2009 9:57 AM
Tuesday, March 3, 2009 2:48 PM
All replies
-
Hi Kevin,
Please try the following. I tested the following. Its working perfectly both in foreground and background mode. Arralist is not required actually. but It was working when I added arraylist. So you try with out arraylist, if not use the code as it is.
private
void button1_Click(object sender, EventArgs e){
this.Hide();}
private ArrayList stateList = new ArrayList(); ActiveSyncStatus syncStatus; private void Form1_Load(object sender, EventArgs e){
SystemState s = new SystemState(SystemProperty.ActiveSyncStatus);s.Changed +=
new ChangeEventHandler(ActiveSyncchanged);stateList.Add(s);
}
private void ActiveSyncchanged(object sender, ChangeEventArgs args){
syncStatus = (
ActiveSyncStatus)args.NewValue; if (syncStatus.Equals(ActiveSyncStatus.Synchronizing)){
MessageBox.Show("Synching");}
}
Please let me know if my code is not solving your problem.
Regards,
Malleswar- Proposed as answer by Malleswara Reddy [MCTS, MCP] Tuesday, March 3, 2009 2:48 PM
- Marked as answer by Kevin Cho Wednesday, March 4, 2009 9:57 AM
Tuesday, March 3, 2009 2:48 PM -
Hi Malleswar,
It works fine.
ThanksWednesday, March 4, 2009 10:00 AM