How to implement C-MOVE in .NET
In the .NET version of DicomObjects, C-MOVE is slightly more complicated but user has a lot more flexibility. Following is VB.NET sample code showing how to do a proper C-MOVE via DicomQuery Object and how to receive C-MOVE responses.
Dim WithEvents server As DicomServer Dim images As New DicomImageCollection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click server = New DicomServer server.Listen(1111) Dim query As New DicomQuery images.Clear() query.Destination = "Local" query.Node = "localhost" query.Port = 104 query.Level = "Enums.QueryLevel.Instance" query.Root = "Enums.QueryRoot.Study" query.InstanceID = "1.2.840.10008.12.3.123.220.127.116.11.3" '.....etc. query.Move() ' by the time the above call returns, the images should have been collected! MsgBox(images.Count) server.Unlisten(1111) server.Dispose() End Sub
C-MOVE reponses are received in the DicomServer.InstanceReceived event as below:
Private Sub server_InstanceReceived(ByVal sender As Object, ByVal e As DicomObjects.DicomServer.InstanceReceivedArgs) Handles server.InstanceReceived images.Add(e.Instance) e.Status = 0 End Sub
This would not have worked in the COM version of DicomObjects (thereby requiring the "GetUsingMove") as there would have been a deadlock, as the InstanceReceived Event could not have fired whilst Move was in progress, but that is no problem in .NET - hence that method is no longer needed.