Thread safe variable management for Custom Classes

Welcome Forums General PowerShell Q&A Thread safe variable management for Custom Classes

Viewing 0 reply threads
  • Author
    Posts
    • #242147
      Participant
      Topics: 6
      Replies: 5
      Points: 27
      Rank: Member

      Issue is I am trying to use parallelization to add a generated object which is a custom object.

       

      My custom class is

      class Foo{

      [string]$AuditArea
      [string]$FooName
      [String]$FooId

      Foo () {}
      }

      $Records =  [System.Collections.Concurrent.Concurrentbag[Foo]]::new()
      $bar = [Foo]::New()
      $Records.tryadd($bar)
      MethodException: Cannot convert argument "item", with value: "", for "TryAdd" to type "Foo": "Cannot convert the "Foo" value of type "Foo" to type "Foo"."
Viewing 0 reply threads
  • You must be logged in to reply to this topic.