<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;

namespace AnimatedBackground
{    
    static class Program
    {
        // DLL Import
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

        // Consts
        const int SPI_SETDESKWALLPAPER = 20;
        const int SPIF_UPDATEINIFILE = 0x01;
        const int SPIF_SENDWININICHANGE = 0x02;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Thread t = new Thread(AnimatedBackground);
            t.Start();            

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run();
        }

        private static void AnimatedBackground()
        {
            Thread.CurrentThread.IsBackground = true;
            Image img = Image.FromFile("Background.gif");            
            FrameDimension dimension = new FrameDimension(img.FrameDimensionsList[0]); //gets the GUID
            int frameCount = img.GetFrameCount(dimension); //total frames in the animation

            int index = 0;

            // Loop forever
            while (true)
            {
                // Grab this index frame
                img.SelectActiveFrame(dimension, index);
                // Convert to a bitmap
                Bitmap frame = (Bitmap)img.Clone();

                // Save this bitmap
                frame.Save("displayImage.bmp");

                // Set the background
                RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
                key.SetValue(@"WallpaperStyle", 1.ToString());
                key.SetValue(@"TileWallpaper", 0.ToString());

                string tempPath = Path.Combine(Application.StartupPath, "displayImage.bmp");
                SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, tempPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
<commit_msg>Need to reopen the file each time, or it will error out after a GC.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.IO;

namespace AnimatedBackground
{    
    static class Program
    {
        // DLL Import
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

        // Consts
        const int SPI_SETDESKWALLPAPER = 20;
        const int SPIF_UPDATEINIFILE = 0x01;
        const int SPIF_SENDWININICHANGE = 0x02;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Thread t = new Thread(AnimatedBackground);
            t.Start();            

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run();
        }

        private static void AnimatedBackground()
        {
            Thread.CurrentThread.IsBackground = true;            

            int index = 0;

            // Loop forever
            while (true)
            {
                // Grab this index frame
                Image img = Image.FromFile("Background.gif");
                FrameDimension dimension = new FrameDimension(img.FrameDimensionsList[0]); //gets the GUID
                int frameCount = img.GetFrameCount(dimension); //total frames in the animation
                img.SelectActiveFrame(dimension, index);
                // Convert to a bitmap
                Bitmap frame = (Bitmap)img.Clone();

                // Save this bitmap
                frame.Save("displayImage.bmp");

                // Set the background
                RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
                key.SetValue(@"WallpaperStyle", 1.ToString());
                key.SetValue(@"TileWallpaper", 0.ToString());

                string tempPath = Path.Combine(Application.StartupPath, "displayImage.bmp");
                SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, tempPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);

{'fraction_non_alphanumeric': 0.0905595899188381, 'fraction_numerical': 0.007261853908586074, 'mean_word_length': 2.0096401028277633, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2421234', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1177, 'n_words': 302}