top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can I port "synchronized" functions from Visual J++ to C#?

+1 vote
314 views
How can I port "synchronized" functions from Visual J++ to C#?
posted Jun 16, 2014 by Anuradha Tabyal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
Original Visual J++ code: public synchronized void Run()
{
// function body
}
Ported C# code: class C
{
public void Run()
{
lock(this)
{
// function body
}
}
public static void Main() {}
}
answer Jun 17, 2014 by Yogeshwar Thakur
Similar Questions
+1 vote

If write this code in form 1 :

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.IO;
using System.Xml.Serialization;

namespace PostLab5_**********
{
    public partial class Form1 : Form
    {
        List<StudentInfo> Stu_Info = new List<StudentInfo>();
        Queue<StudentInfo> pass = new Queue<StudentInfo>();
        Queue<StudentInfo> fail = new Queue<StudentInfo>();
        Stack<StudentInfo> Excelent = new Stack<StudentInfo>();
        Stack<StudentInfo> VeryGood = new Stack<StudentInfo>();
        Stack<StudentInfo> Good = new Stack<StudentInfo>();
        public Form1()
        {
            InitializeComponent();
        }

        private void importXMLToolStripMenuItem_Click(object sender, EventArgs e)
        {

            OpenFileDialog Dlg = new OpenFileDialog();
            Dlg.Filter = "XML File|*.xml";
            if (Dlg.ShowDialog() == DialogResult.OK)
            {
                StreamReader Infile = new StreamReader(Dlg.FileName);
                XmlSerializer Des = new XmlSerializer(typeof(List<StudentInfo>));
                Stu_Info = (List<StudentInfo>)Des.Deserialize(Infile);
                Infile.Close();
                dataGridView1.DataSource = Stu_Info;
            }
        }

        private void passedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var R = from Item in Stu_Info
                    where Item.total >= 50
                    select Item;
            dataGridView1.DataSource = R.ToArray();
            foreach (StudentInfo item in R)
            {
                pass.Enqueue(item);
            }
        }

        private void failedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var R = from Item in Stu_Info
                    where Item.total < 50
                    select Item;
            dataGridView1.DataSource = R.ToArray();
            foreach (StudentInfo item in R)
            {
                fail.Enqueue(item);
            }
        }

        private void excellentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var R = from Item in Stu_Info
                    where Item.total >= 84
                    select Item;
            dataGridView1.DataSource = R.ToArray();
            foreach (StudentInfo Item in R)
            {
                Excelent.Push(Item);
            }
        }

        private void veryGoodToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var R = from Item in Stu_Info
                        where Item.total >=76 && Item.total <84
                        select Item;
                dataGridView1.DataSource = R.ToArray();
                foreach (StudentInfo Item in R)
                {
                    VeryGood.Push(Item);
                }
            }

        private void goodToolStripMenuItem_Click(object sender, EventArgs e)
        {
             var R = from Item in Stu_Info
                        where Item.total >= 68 && Item.total < 76
                        select Item;
                dataGridView1.DataSource = R.ToArray();
                foreach (StudentInfo Item in R)
                {
                    Good.Push(Item);
                }
        }

        private void countOfVeryGoodToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show(VeryGood.Count().ToString());
        }

        private void peekOfPeekToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show(Good.Peek().name);
        }

        private void removeItemFromFailedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show(fail.Dequeue().name);
        }

        private void countOfPassedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show(pass.Count().ToString());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();

        }
        }
    }

and in form2 contain textboxes to add new item for these list ! how use this !

+5 votes

I wanna display only google map without other web page elements, and add some buttons to control the map like zoom in and zoom out.

...