|
2 | 2 | title: "Event Sources (Visual Studio SDK) | Microsoft Docs"
|
3 | 3 | ms.date: "11/04/2016"
|
4 | 4 | ms.topic: "conceptual"
|
5 |
| -helpviewer_keywords: |
| 5 | +helpviewer_keywords: |
6 | 6 | - "debugging [Debugging SDK], event sources"
|
7 | 7 | ms.assetid: b9ba0908-ae4c-4a64-aab1-bee453dd7a22
|
8 | 8 | author: "gregvanl"
|
9 | 9 | ms.author: "gregvanl"
|
10 | 10 | manager: jillfra
|
11 |
| -ms.workload: |
| 11 | +ms.workload: |
12 | 12 | - "vssdk"
|
13 | 13 | ---
|
14 | 14 | # Event sources (Visual Studio SDK)
|
15 |
| -There are two sources of events: the debug engine (DE) and the Session Debug Manager (SDM). Events sent from a DE have a non-NULL engine, while events sent from the SDM have a NULL engine. |
16 |
| - |
17 |
| -## Example |
18 |
| - The following example shows how to send the **IDebugProgramCreateEvent2** from the DE to the SDM. |
19 |
| - |
20 |
| -```csharp |
21 |
| -CDebugProgramCreateEvent* pProgramCreateEvent = new CDebugProgramCreateEvent(); |
22 |
| -if (FAILED(pCallback->Event(m_pEngine, NULL, m_pProgram, NULL, pProgramCreateEvent, IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS))) |
23 |
| -{ |
24 |
| - // Handle failure here. |
25 |
| -} |
26 |
| -] |
27 |
| - |
28 |
| -CEvent * pProgCreate = new CEvent(IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS); |
29 |
| -pProgCreate->SendEvent(pCallback, m_pEngine, (IDebugProgram2 *)this, NULL); |
30 |
| - |
31 |
| -HRESULT CEvent::SendEvent(IDebugEventCallback2 *pCallback, IDebugEngine2 *pEngine, IDebugProgram2 *pProgram, IDebugThread2 *pThread) { |
32 |
| - HRESULT hr; |
33 |
| - |
34 |
| - if (m_dwAttrib & EVENT_STOPPING) |
35 |
| - { |
36 |
| - hr = SendStoppingEvent(pCallback, pEngine, pProgram, pThread); |
37 |
| - } |
38 |
| - else if (m_dwAttrib & EVENT_SYNCHRONOUS) |
39 |
| - { |
40 |
| - hr = SendSynchronousEvent(pCallback, pEngine, pProgram, pThread); |
41 |
| - } |
42 |
| - else |
43 |
| - { |
44 |
| - assert(m_dwAttrib == 0); |
45 |
| - hr = SendAsynchronousEvent(pCallback, pEngine, pProgram, pThread); |
46 |
| - } |
47 |
| - |
48 |
| - return hr; |
49 |
| -} |
50 |
| - |
51 |
| -HRESULT CEvent::SendAsynchronousEvent(IDebugEventCallback2 *pCallback, IDebugEngine2 *pEngine, IDebugProgram2 *pProgram, IDebugThread2 *pThread) { |
52 |
| - |
53 |
| - HRESULT hr; |
54 |
| - |
55 |
| - // Make sure the CEvent object running this code is not deleted until the code completes. |
56 |
| - AddRef(); |
57 |
| - |
58 |
| - pCallback->Event(pEngine, NULL, pProgram, pThread, (IDebugEvent2 *)this, m_riid, m_dwAttrib); |
59 |
| - |
60 |
| - // No error recovery here. |
61 |
| - hr = S_OK; |
62 |
| - |
63 |
| - Release(); |
64 |
| - return hr; |
65 |
| -} |
66 |
| - |
67 |
| -``` |
68 |
| - |
69 |
| -## See also |
70 |
| - [Sending events](../../extensibility/debugger/sending-events.md) |
| 15 | +There are two sources of events: the debug engine (DE) and the Session Debug Manager (SDM). Events sent from a DE have a non-NULL engine, while events sent from the SDM have a NULL engine. |
| 16 | + |
| 17 | +## Example |
| 18 | +The following example shows how to send the **IDebugProgramCreateEvent2** from the DE to the SDM. |
| 19 | + |
| 20 | +```csharp |
| 21 | +CDebugProgramCreateEvent* pProgramCreateEvent = new CDebugProgramCreateEvent(); |
| 22 | +if (FAILED(pCallback->Event(m_pEngine, NULL, m_pProgram, NULL, pProgramCreateEvent, IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS))) |
| 23 | +{ |
| 24 | + // Handle failure here. |
| 25 | +} |
| 26 | +] |
| 27 | + |
| 28 | +CEvent * pProgCreate = new CEvent(IID_IDebugProgramCreateEvent2, EVENT_ASYNCHRONOUS); |
| 29 | +pProgCreate->SendEvent(pCallback, m_pEngine, (IDebugProgram2 *)this, NULL); |
| 30 | + |
| 31 | +HRESULT CEvent::SendEvent(IDebugEventCallback2 *pCallback, IDebugEngine2 *pEngine, IDebugProgram2 *pProgram, IDebugThread2 *pThread) { |
| 32 | + HRESULT hr; |
| 33 | + |
| 34 | + if (m_dwAttrib & EVENT_STOPPING) |
| 35 | + { |
| 36 | + hr = SendStoppingEvent(pCallback, pEngine, pProgram, pThread); |
| 37 | + } |
| 38 | + else if (m_dwAttrib & EVENT_SYNCHRONOUS) |
| 39 | + { |
| 40 | + hr = SendSynchronousEvent(pCallback, pEngine, pProgram, pThread); |
| 41 | + } |
| 42 | + else |
| 43 | + { |
| 44 | + assert(m_dwAttrib == 0); |
| 45 | + hr = SendAsynchronousEvent(pCallback, pEngine, pProgram, pThread); |
| 46 | + } |
| 47 | + |
| 48 | + return hr; |
| 49 | +} |
| 50 | + |
| 51 | +HRESULT CEvent::SendAsynchronousEvent(IDebugEventCallback2 *pCallback, IDebugEngine2 *pEngine, IDebugProgram2 *pProgram, IDebugThread2 *pThread) { |
| 52 | + |
| 53 | + HRESULT hr; |
| 54 | + |
| 55 | + // Make sure the CEvent object running this code is not deleted until the code completes. |
| 56 | + AddRef(); |
| 57 | + |
| 58 | + pCallback->Event(pEngine, NULL, pProgram, pThread, (IDebugEvent2 *)this, m_riid, m_dwAttrib); |
| 59 | + |
| 60 | + // No error recovery here. |
| 61 | + hr = S_OK; |
| 62 | + |
| 63 | + Release(); |
| 64 | + return hr; |
| 65 | +} |
| 66 | + |
| 67 | +``` |
| 68 | + |
| 69 | +## See also |
| 70 | +[Sending events](../../extensibility/debugger/sending-events.md) |
0 commit comments