Click here to Skip to main content
15,914,447 members
Home / Discussions / C#
   

C#

 
AnswerRe: connect db to crystal report Pin
Tyler455-Jan-07 12:22
Tyler455-Jan-07 12:22 
GeneralRe: connect db to crystal report Pin
amilapradeep6-Jan-07 18:58
amilapradeep6-Jan-07 18:58 
QuestionDo you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 16:39
JoeRip4-Jan-07 16:39 
AnswerRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 18:15
Phillip M. Hoff4-Jan-07 18:15 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 18:34
JoeRip4-Jan-07 18:34 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 18:41
JoeRip4-Jan-07 18:41 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 19:08
Phillip M. Hoff4-Jan-07 19:08 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 19:50
Phillip M. Hoff4-Jan-07 19:50 
I wrote a simple little iTunes listener that shows similar odd behavior. It's just a WinForm application that has a text box that is updated with the new volume as it is changed within iTunes.

    public partial class Form1 : Form<br />
    {<br />
        private iTunesLib.iTunesApp app;<br />
<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
<br />
            app = new iTunesLib.iTunesApp();<br />
<br />
            app.OnSoundVolumeChangedEvent += new iTunesLib._IiTunesEvents_OnSoundVolumeChangedEventEventHandler(app_OnSoundVolumeChangedEvent);<br />
        }<br />
<br />
        void app_OnSoundVolumeChangedEvent(int newVolume)<br />
        {<br />
            // Update works!<br />
            //if (InvokeRequired)<br />
            //{<br />
            //    Invoke(new iTunesLib._IiTunesEvents_OnSoundVolumeChangedEventEventHandler(app_OnSoundVolumeChangedEvent), new object[] { newVolume });<br />
            //}<br />
            //else<br />
            //{<br />
            //    textBox1.Text = String.Format("{0}: {1}\r\n{2}", DateTime.Now, newVolume, textBox1.Text);<br />
            //}<br />
<br />
            // Update doesn't work!<br />
            textBox1.Text = String.Format("{0}: {1}\r\n{2}", DateTime.Now, newVolume, textBox1.Text);<br />
        }<br />
    }


When the application is run and the volume is changed in iTunes, the textbox won't show the updates (or will, but not dependably). If you comment the "doesn't work" code and uncomment the "works" code, all the updates are displayed. What the example demonstrates is the need to make all updates to the UI on the UI thread, else the behavior of the UI can be undefined. This includes, as far as I know anyway, updates to data bound to UI elements (because those updates indirectly trigger updates to the UI).

(I apologize if this is all old-hat to you already.)

-Phil
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:04
JoeRip4-Jan-07 20:04 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 20:22
Phillip M. Hoff4-Jan-07 20:22 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:31
JoeRip4-Jan-07 20:31 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:45
JoeRip4-Jan-07 20:45 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 21:05
Phillip M. Hoff4-Jan-07 21:05 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 21:12
JoeRip4-Jan-07 21:12 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 21:25
Phillip M. Hoff4-Jan-07 21:25 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 21:34
JoeRip4-Jan-07 21:34 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Phillip M. Hoff4-Jan-07 21:45
Phillip M. Hoff4-Jan-07 21:45 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 21:47
JoeRip4-Jan-07 21:47 
GeneralRe: Do you know of a MS COM object that raises events? Pin
Luc Pattyn5-Jan-07 4:22
sitebuilderLuc Pattyn5-Jan-07 4:22 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:15
JoeRip4-Jan-07 20:15 
GeneralRe: Do you know of a MS COM object that raises events? Pin
JoeRip4-Jan-07 20:20
JoeRip4-Jan-07 20:20 
QuestionVirus Pin
Tyler454-Jan-07 15:45
Tyler454-Jan-07 15:45 
AnswerRe: Virus [modified] Pin
Vega024-Jan-07 16:06
Vega024-Jan-07 16:06 
AnswerRe: Virus Pin
leppie4-Jan-07 16:54
leppie4-Jan-07 16:54 
AnswerRe: Virus Pin
Christian Graus4-Jan-07 18:03
protectorChristian Graus4-Jan-07 18:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.