dotnet / dotnet/dotnet-api-docs
GC.ReRegisterForFinalize(Object) Method – object arg/param is not limited to caller
- Lingua principale
- C#
- Stelle
- 949
- Fork
- 1.7k
- Merge medio
- 2g 19h
- PR unite (30g)
- 52
Descrizione
From [Remarks](https://docs.microsoft.com/en-us/dotnet/api/system.gc.reregisterforfinalize?view=net-5.0#remarks)
> The ReRegisterForFinalize method adds the obj parameter to the list of objects that request finalization before the garbage collector frees the object. The obj parameter must be the caller of this method.
Verifying example one can gather no error on `GC.ReRegisterForFinalize (new object());` call.
```csharp
class Program
{
static async Task Main ( string[] args )
{
Test test;
foreach(var i in Enumerable.Range(0, 2))
test = new Test ();
test = null;
GC.Collect ();
await Task.Delay (1_000);
}
class Test
{
~Test ()
{
Console.WriteLine ("AAAA");
GC.ReRegisterForFinalize (this);
GC.ReRegisterForFinalize (new object());
}
}
}
```
### Project
[GcReRegisterForFinalize.zip](https://github.com/dotnet/docs/files/7148204/GcReRegisterForFinalize.zip)
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dalla documentazione collegata di ReRegisterForFinalize Remarks e dalla riproduzione C# fornita, quindi verifica cosa comporta la restrizione sul parametro obj per il comportamento osservato. Il lavoro è completato quando la documentazione dell’API spiega accuratamente se la restrizione sul chiamante viene applicata e come deve essere interpretato l’esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100