How do I properly Get CDInfo synchronously

Hi, and thanks to anyone who can help. I am using VS2005 C# and NeroCom.

I am trying to get INeroCDInfo synchronously. I would like to get the FreeCapacityInBlocks, but I want the method to block.

I simply need to determine if the DVD has enough free space.
Here is a terrible version of what I am trying to accomplish:

private void button3_Click(object sender, EventArgs e)
// Client Code
UInt64 x = GetFreeSpace(0);
Console.WriteLine(x *2048);
// Global variable
INeroCDInfo neroCdInfo = null;

private UInt64 GetFreeSpace(Int32 deviceID)
Nero nero = new Nero();
NeroDrives neroDrives = nero.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_DVD_ANY);
NeroDrive neroDrive = neroDrives.Item(deviceID) as NeroDrive;
if (neroDrive.DeviceReady)
neroDrive.OnDoneCDInfo += new _INeroDriveEvents_OnDoneCDInfoEventHandler(neroDrive_OnDoneCDInfo);
while (neroCdInfo == null)
// Don’t you just love this next line???
UInt64 xx = (UInt64)neroCdInfo.FreeCapacityInBlocks;
return xx;
throw new Exception(“Drive not ready”);
// Nero Event
void neroDrive_OnDoneCDInfo(INeroCDInfo pCDInfo)
neroCdInfo = pCDInfo;

ok, I don’t work in C# but I can follow. So what is happening with this code? Is it never sending back your free space? To me it looks like it should eventually, and if it isn’t have you tried not doing this synchronously? I use and I do the following:

''I first call the event if the drive is ready
Private Sub cmbdrives_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbdrives.SelectedIndexChanged
activedrive = drives.Item(cmbdrives.SelectedIndex)

    If activedrive.DeviceReady = True Then
        lbldrivestatus.Text = "READY"
    Else : lbldrivestatus.Text = "NOT READY"
    End If
End Sub

''and then here in another sub which would be your
void neroDrive_OnDoneCDInfo(INeroCDInfo pCDInfo) I do this:

Private Sub activedrive_OnDoneCDInfo(ByVal pCDInfo As NEROLib.INeroCDInfo) Handles activedrive.OnDoneCDInfo
dim remainingspace as integer
If Not pCDInfo Is Nothing Then
remainingspace = Math.Round((pCDInfo.FreeCapacityInBlocks * 2) / 1024)
End if
End Sub

try not waiting for the event inside your one sub with the while statement, and inside your void neroDrive_OnDoneCDInfo(INeroCDInfo pCDInfo) sub write out the remaining space to console. If this must be a synchronous operation then please post back stating what is happening when you run this code.

That happened to me as well…

My solution was to use a delegate as a wrapper around my synchronous CDInfo function, and call BeginInvoke, EndInvoke on the delegate instead… Works for me after that…