Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryComplete() [1/2]

override bool System.Threading.Channels.SingleConsumerUnboundedChannel< T >.UnboundedChannelWriter.TryComplete ( Exception error)
inline

Definition at line 158 of file SingleConsumerUnboundedChannel.cs.

159 {
162 bool flag = false;
164 lock (parent.SyncObj)
165 {
166 if (parent._doneWriting != null)
167 {
168 return false;
169 }
170 parent._doneWriting = error ?? ChannelUtilities.s_doneWritingSentinel;
171 if (parent._items.IsEmpty)
172 {
173 flag = true;
174 if (parent._blockedReader != null)
175 {
176 asyncOperation = parent._blockedReader;
177 parent._blockedReader = null;
178 }
179 if (parent._waitingReader != null)
180 {
181 asyncOperation2 = parent._waitingReader;
182 parent._waitingReader = null;
183 }
184 }
185 }
186 if (flag)
187 {
188 ChannelUtilities.Complete(parent._completion, error);
189 }
190 if (asyncOperation != null)
191 {
192 error = ChannelUtilities.CreateInvalidCompletionException(error);
193 asyncOperation.TrySetException(error);
194 }
195 if (asyncOperation2 != null)
196 {
197 if (error != null)
198 {
199 asyncOperation2.TrySetException(error);
200 }
201 else
202 {
203 asyncOperation2.TrySetResult(item: false);
204 }
205 }
206 return true;
207 }

References System.Threading.Channels.SingleConsumerUnboundedChannel< T >.UnboundedChannelWriter._parent, System.Threading.Channels.ChannelUtilities.Complete(), System.Threading.Channels.ChannelUtilities.CreateInvalidCompletionException(), System.item, and System.Threading.Channels.ChannelUtilities.s_doneWritingSentinel.