// Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the MIT license.usingSystem.Threading.Tasks;namespaceSystem.Device.Gpio.Tests{publicstaticclassTimeoutHelper{publicstaticvoidCompletesInTime(Actiontest,TimeSpantimeout){Tasktask=Task.Run(test);boolcompletedInTime=Task.WaitAll(new[]{task},timeout);if(task.Exception!=null){if(task.Exception.InnerExceptions.Count==1){throwtask.Exception.InnerExceptions[0];}throwtask.Exception;}if(!completedInTime){thrownewTimeoutException($"Test did not complete in the specified timeout: {timeout.TotalSeconds} seconds.");}}}}