Bonjour a tous, tout est dans le titre :
voici un code que je suis en train de tester :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net;
using System.Threading;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
 
 
    public partial class Form1 : Form
    {
        [DllImport("dnsapi.dll", EntryPoint = "DnsFlushResolverCache")]
        private static extern UInt32 DnsFlushResolverCache();
 
        public static void FlushMyCache() //This can be named whatever name you want and is the function you will call
        {
            UInt32 result = DnsFlushResolverCache();
        }
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            while (true)
            {
                IPHostEntry hosts;
                hosts = Dns.GetHostEntry("www.google.fr");
                FlushMyCache();
                for (int index = 0; index < hosts.AddressList.Length; index++)
                {
                    Debug.WriteLine(hosts.AddressList[index]);
                }
                Thread.Sleep(1000);
            }
        }
    }
}
Comme vous pouvez le voir, je fais mon office dans l'initialisation de la première fenêtre. ça marches, c'est cool.
Maintenant, existe t il un moyen de faire cela de manière propre ( ne pas faire tourner ma boucle dans l'initialisation )? Je ne suis pas obligé d'utiliser les forms window et le soft DOIT être lancé a la main ( double click ).

Tartine