Opc.Ua.Com.Client.EnumString.Next C# (CSharp) Method

Next() public method

Fetches the next group of strings.
public Next ( string buffer, int count ) : int
buffer string
count int
return int
		public int Next(string[] buffer, int count)
		{
            // can't use simple interface after calling this method.
            m_fetched = -1;

			try
			{
				int fetched = 0;

                IntPtr pBuffer = Marshal.AllocCoTaskMem(IntPtr.Size*count);
                
                try
                {
				    int error = m_enumerator.RemoteNext(
					    count,
                        pBuffer,
					    out fetched);

                    if (error >= 0 && fetched > 0)
				    {
                        IntPtr[] pStrings = new IntPtr[m_fetched];
                        Marshal.Copy(pBuffer, pStrings, 0, fetched);

                        for (int ii = 0; ii < fetched; ii++)
		                {
                            m_buffer[ii] = Marshal.PtrToStringUni(pStrings[ii]);
                            Marshal.FreeCoTaskMem(pStrings[ii]);
		                }
                    }

                    return fetched;
                }
                finally
                {
                    Marshal.FreeCoTaskMem(pBuffer);
                }
			}
			catch (Exception e)
			{
				// some (incorrect) implementations return E_FAIL at the end of the list.
                if (Marshal.GetHRForException(e) == ResultIds.E_FAIL)
                {
				    return 0;
                }

                throw ComUtils.CreateException(e, "IEnumString.RemoteNext");
			}
		}

Same methods

EnumString::Next ( ) : string