<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 12.03.2009, at 08:12, <a href="mailto:Matthias.Ritter@metop.de">Matthias.Ritter@metop.de</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><font size="3">Unfortunatly it still doesn't work.</font> <br><font size="3">Of course my first try was with "WINAPI", that changes nothing.</font> <br><font size="3">I reduced my code on a minimum and it looks like that:</font> <br> <br><font size="3">The Main-function:</font> <br> <br><font size="2" color="blue">int</font><font size="2"> main( </font><font size="2" color="blue">void</font><font size="2"> )</font> <br><font size="2">{</font> <br><font size="2">        Sleep( 1000 );</font> <br><font size="2">        cout << "in main function" << endl;</font> <br><font size="2">        getchar();</font> <br><font size="2">        </font><font size="2" color="blue">return</font><font size="2"> 0;</font> <br><font size="2">}</font> <br> <br><font size="3">my aspect:</font> <br> <br><font size="2">aspect foo</font> <br><font size="2">{</font> <br><font size="2">                HANDLE myThread;</font> <br><font size="2">                </font><font size="2" color="blue">int</font><font size="2"> ThreadArgs;</font> <br><font size="2">                </font><font size="2" color="blue">int</font><font size="2"> myThreadId;</font> <br><font size="2">                pointcut Main() = execution("% main(...)");</font> <br> <br><font size="2">                DWORD WINAPI bar(</font><font size="2" color="blue">void</font><font size="2">* param)</font> <br><font size="2">                {</font> <br><font size="2">                        cout << "in Thread-Function" << endl;</font> <br><font size="2">                        </font><font size="2" color="blue">return</font><font size="2"> 0;</font> <br><font size="2">                }</font> <br> <br><font size="2">                advice Main() : before()</font> <br><font size="2">                {</font> <br><font size="2">                        cout << "aspect before main" << endl;</font> <br><font size="2">                        myThread = CreateThread( NULL, 0, bar, (</font><font size="2" color="blue">void</font><font size="2">*)&ThreadArgs, 0, (LPDWORD)&myThreadId );</font> <br><font size="2">                }</font> <br> <br><font size="2">                advice  Main() : after()</font> <br><font size="2">                {</font> <br><font size="2">                        cout << "aspect after Main" << endl;</font> <br><font size="2">                        TerminateThread (myThread, 0);</font> <br><font size="2">                        CloseHandle(myThread);</font> <br><font size="2">                }</font> <br><font size="2">};</font> <br> <br><font size="3">I tried the 3 lines "CreateThread", "TerminateThread" and "CloseHandle" in an own main without weaving an aspect, and it works.</font> <br><font size="3">Without the "CreateThread" call the aspect works fine.</font> <br></blockquote></div><br><div><br></div><div>Your bar() function seems to be a member of the aspect. Non-static member functions (aspects behave like classes in this respect) cannot be used directly as C-style callbacks, as expected by CreateThread() for the thread function. You can work around this by turning bar() into a static member function:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>static DWORD WINAPI bar(void* param);</div><div><br></div><div>Note that all this signature-errors and type-compatibility-issues are not so much related to AspectC++ but to C++ in general. You might want to try your code with a plain class first. Just make your aspect a class and every advice a member function of the class and see if that compiles.</div><div><br></div><div>Daniel  </div></body></html>